Your code creates a new object and immediately discards its link to it.
This happens when you call a function that returns a value without assigning it to a variable:
int foo() {
System.out.println("Ron Paul 2016!");
return 42;
}
public static void main(String... args) {
foo();
}
Nothing is done here with the return value from foo(), but the call println()will still be executed (and your code will be compiled and life will continue).
, ( , LwjglApplication) . . ( RafazZ , , , , API- .)
, .
, , :
class Foo {
void bar() {
System.out.println(this.getClass());
}
public static void main(String... args) {
(new Foo()).bar();
}
}
, Foo, bar().