// loneobject // you do not need instance variables to create objects! class Thing { public int blah; public Thing() {}; public Thing(int b) { blah = b; } public Thing something(int b) { return new Thing(b); } } public class loneobject { public static void main(String[] args) { // create object and directly access a field: System.out.println( (new Thing(1)).blah ); // create object inside a method call: System.out.println( new Thing().something(2).blah ); } } /* Output: 1 2 */