0

because I couldn't find anything in google that would explain that, I decided to turn myself to ask you what the arrow in this specific example does, I never saw that expression so I don't really get it what it does.

Site I try to learn from: http://zetcode.com/tutorials/javagamestutorial/basics/

Thanks for helping!~

   public static void main(String[] args) {

        EventQueue.invokeLater(() -> {
            Application ex = new Application();
            ex.setVisible(true);
        });
    }
Machavity
  • 30,841
  • 27
  • 92
  • 100
zapole
  • 39
  • 4

1 Answers1

1

It's part of a lambda expression, which is a shorthand for defining functions. This creates a class with a method that takes no arguments and executes the statement block.

() -> {
    Application ex = new Application();
    ex.setVisible(true);
}
jspcal
  • 50,847
  • 7
  • 72
  • 76
  • Thanks I'll look it up and thanks for the short explenation, it already made it easier to read through! ~ – zapole Jun 09 '18 at 00:42
  • Okay I guess I get it, by anonymous you mean they are public but not accessible from outside (kinda private) since there is no name to call it from other classes. – zapole Jun 09 '18 at 00:52
  • 1
    It's similar to an anonymous class: `() -> some.function(call)` is shorthand for `new Runnable() {@Override void run() {some.function(call);}`, or whatever actual type the expression requires. – jspcal Jun 09 '18 at 01:11