What do you mean by returning a static method? In my opinion, you can call a static method an instance method, of course, depending on the circumstances. Could you post the code that Netbeans complains about?
One thing I could imagine was to use only static methods from an instance method without using any instance data. Sometimes this is what is required to implement an interface or override a method from the base class, but if you do not override anything and you do not use any instance variables, it is nice to make the method static to show that it really does not depend on a specific instance.
EDIT: With an edited question this makes a lot of sense. IMO is a flaw in Java that allows this in the first place. This can be very misleading code. My favorite example (which means that the old-timers may have seen me post it before :) with Thread.sleep . What does this code look like?
Thread t = new Thread(someRunnable); t.start(); t.sleep(1000);
In my opinion, it seems that the new thread is being asked to sleep - like calling suspend . But no - you can only ask that the current executable thread is sleeping, so Thread.sleep is a static method. The above code is legal Java and will make an executable thread thread for a second, while the thread just created (probably) works ... it doesn't look at all what the code looks like at first glance.
source share