Hey i know this is a stupid question, but i have no idia how to google it.
I have copied this code directly from a book:

Btw, my main() method is empty.

package benytterning;

public class Terning
{
    
    public int værdi;

    public Terning()
    {
            kast(); 
    }

    public void kast()
    {
            double tilfældigtTal = Math.random();
            værdi = (int) (tilfældigtTal * 6 + 1);
    }
    
    public String toString()
    {
            String svar = ""+værdi;  // værdi som streng, f.eks. "4"
            return svar;
    }
}

And my compiler says this:

Exception in thread "main" java.lang.UnsupportedClassVersionError: benytterning/BenytTerning : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

Netbeans also tell me that i need to @overide the toString() method?
And that i need to make kast() private or static or final. (btw i have no idia what static and final means)

Hope someone can help. Because i really can't see whats wrong.

Solved. I need to update my JDK . And I'm on mac, so not posible..... FU apple.

I suggest to deal with the errors netbeans found before trying to run it

@override

Read this and maybe search google for more info
http://stackoverflow.com/questions/561365/what-is-override-for-in-java

(btw i have no idia what static and final means)

Still the same,If you doubt their purpose or use you can always search the net on why you need to use them like so
http://docs.oracle.com/javase/tutorial/java/IandI/final.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.