Reputation: 25
So I was trying to figure out how this snake game works:
http://zetcode.com/tutorials/javagamestutorial/snake/
When I copied the code into a compiler, I got many errors in this one block of code:
public static void main(String[] args) {
EventQueue.invokeLater(() -> {
JFrame ex = new Snake();
ex.setVisible(true);
});
}
}
Here are the errors: (Line 27 is the EventQueue.invokeLater line)
Error: illegal start of expression (Line 27)
Error: illegal start of expression (Line 27)
Error: illegal start of expression (Line 27)
Error: ';' expected (Line 27)
Error: illegal start of type (Line 30)
Error: class, interface, or enum expected (Line 32)
Upvotes: 0
Views: 386
Reputation: 12603
You need to have at least Java 8 for using Lambdas (like you do in this example).
For Java 7, you'll need to resort to resort to using Runnable
instead of Lambda
EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame ex = new Snake();
ex.setVisible(true);
}
});
Upvotes: 1