i want to make a program that contains two main classes and they call each other.
class Main1
{
public static void main(String arg[])
{
for(int i=0;i<5;i++)
System.out.println(i);
Main2 m1=new Main2();
}
}
class Main2
{
public static void main(String arg[])
{
static int j=0;
for(int i=0;i<5;i++)
System.out.println(i);
if(j==3)
break;
j++;
Main1 m1=new Main2();
}
}
it is the code that i implemented. i use static variable so that i can control the no of calls but this shows an error when i use static variable.
please solve it for me..