Search code examples
javaeclipsekeyboard-shortcuts

keyboard shortcut for class object in eclipse


class Demo{
    static void  Test(){
        System.out.println("hello");
    }
}

Is there any keyboard shortcut in eclipse for creating an object of a class declared above .

e.g after writing Demo followed by that shortcut , it should write as below

Demo objname = new Demo();

Solution

  • I don't think you can do exactly that, but this is close:

    Type new Demo() then ctrl-2 L (Quick Assist - Assign to local variable).

    Eclipse will change the line to Demo demo = new Demo(); and give you a chance to rename the variable.