Skip to Main Content

Java Programming

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!

How to access a static method in a static way?

807569May 17 2006 — edited Aug 6 2006
Hi,

I have written two program as below:

myProgram.java

public class myProgram{
testStatic ts;

public void test(){
ts = new testStatic();
int a = ts.myName();
}
}

testStatic.java
public class testStatic{
public static int myPrinter(){
System.out.println("This is testStatic class");
return 1;
}
}

When I compile the program, I got a warning at the line code
int a = ts.myName() of class myProgram indicationg that the static method myPrinter() from the type testStatic should be accessed in a static way.

How can i get ride of this warning sign by practising the correct way of accessing a static method?

Please guide.

Thank you!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 3 2006
Added on May 17 2006
5 comments
1,882 views