
Hello All
for example
public class A
{
static void main(String args[])
{
System.out.println("Hello World");
}
}
i have save this program with A.java. Then I executed this program javac A.java no errors and java A [output Hello World],up to this fine. Then I saved the same program with Test.java and try to compile with javac test.java an error like test.java :2 : class A is public ,should be declared in a file named A.java public class A ^
but if i remove public before class then the test.java is compiled.
so my question is why it is not compiled when the class declared as public,and why it compiled when class not declared as public.
what's the actual process is done when class declared as public and not as public.
please any one reply to this.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.