I know that C++ supports static variables in a method and in java, static members are shared among all objects.but why this code fails to compile in java?
class Learn
{
static int count = 0;
Learn(int n)
{
count+=n;
}
public void method()
{
static int count =0;
}
}
public class th
{
public static void main(String a[])
{
Learn l = new Learn(4);
}
}