Can i access static class to another class without using object for that static class. help me how to access.
Asked
Active
Viewed 277 times
-6
-
1Please show some code or further describe the problem - I've no idea what you're asking here? Is it really about Java, javascript and JSON? – home Jan 03 '12 at 05:22
-
You can directly access `static` methods. Like `MyClass.statMeth();`. You don't need to create object/instance. – Vaandu Jan 03 '12 at 05:23
-
you don't have time to ask a short question. :-) – Tae-Sung Shin Jan 03 '12 at 05:23
1 Answers
0
I hope your question is more of accessing class static variables/methods in another class. If so, yes you can.
public class TestStatic
{
public static int x =10;
}
public class YourClass
{
public void yourMethod()
{
int yourVar = TestStatic.x;
}
}
If you are referring accessing static inner classes, here is a good discussion static inner class discussion