hey I saw some code on the internet where there were multiple classes in the same file and so I wrote my own version.
Could someone please tell me how this works? So the first class created has a "public" visibility but all the classes which are declared
after it cannot be declared either public, private or protected. I just don't know what the relationship is between each of these classes, and what it means to declare a class without any specified visiblity, coudd someone please explain this. i've noticed i can have ALL these classes specified without any visibility but if i change the first to "class multi" and make the second class public myClassOne, this causes a compile error.
Thanks
package MultiClassOneFile;
public class Multi {
public static void main(String[] args){
System.out.println(args[0]+" "+args[1]+" "+args[2]);
}
}
class myClassOne {
public static void main(String[] args){
System.out.println(args[0]+" "+args[1]);
}
public void printOut(){
System.out.println("This is myClassOne");
}
}
class myClassTwo {
public static void main(String[] args){
System.out.println(args[0]+" "+args[1]+" "+args[2]);
}
public void printOutAgain(){
System.out.println("This is myClassTwo");
}
}