Doubt in java programming.
class cHere we have to declare static void meth()
{
static int x;
public static void meth()//must be static
{
System.out.println("x= "+x);
}
}
public class r
{
public static void main(String args[])
{
c t=new c();
c.meth();
}
}
But look at this one
public class rhere it's not necessary to declare meth as static anybody tell me the reason.
{
int p;
public void meth(int k)
{
p=k;
System.out.println("p= "+p);
}
public static void main(String args[])
{
r t=new r();
t.meth(5);
}
}
😁