Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

can we call a static method without mentioning the class name

800304Apr 11 2010 — edited Apr 19 2010
public class Stuff {
     public static final int MY_CONSTANT = 5;
     public static int doStuff(int x){ return (x++)*x;}
}
import xcom.Stuff.*;
import java.lang.System.out;
class User {
   public static void main(String[] args){
   new User().go();
   }
   void go(){out.println(doStuff(MY_CONSTANT));}
}
Will the above code compile?
can be call a static method without mentioning the class name?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 17 2010
Added on Apr 11 2010
10 comments
1,109 views