I am not able to figure out what's wrong with the following code:
Is it a rule to create objects in class that contains main method and then use this object to access the methods?
I did exactly reverse in the following code and i am not able to compile it.
class Twoclass
{
Oneclass obj1=new Oneclass();
obj1.show();
}
public class Oneclass
{
public static void main(String args[])
{
System.out.println("Hallowee");
}
public void show()
{
System.out.println("howjk");
}
}
obj1.show();
It is giving the errror as identifier expected on line obj1.show();