javamethodssyntaxeventqueue

eventqueue meaning of arrow


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);
        });
    }

Solution

  • 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);
    }