[Solved] In JAVA, can we use predefined class name as a variable name? [closed]


Yes, we can use predefined class name as variable. following code will work perfectly

public class Test
{
    public static void main(String[] args) 
    {
        int BufferedOutputStream = 3; //BufferedOutputStream is predefined class
        System.out.println(BufferedOutputStream);
    }
}

it is also possible to use user defined class name as variable name. example

public class Test
{
    public static void main(String[] args) 
    {
        Test2 Test2 = new Test2();
        System.out.println(Test2.a);
    }
}

public class Test2
{
    public int a = 2;
}

solved In JAVA, can we use predefined class name as a variable name? [closed]