Home > Back-end >  Have a big help to see?
Have a big help to see?

Time:09-20

Public class Student48
{
//name
String name;
//student number
Int no;
//gender
Boolean sex;

Public class OOTest
{
Public static void main (String [] args) {
Student48 s=new Student48 ();
S.n ame="yuehan";
S.n o=48;
S.s ex=false;
System. The out. Println (s.n ame);
System. The out. Println (s.n o);
System. The out. Println (s.s ex);

}
}
The Exception in the thread "main" Java. Lang. IllegalAccessError: class OOTest tried to access the field Student48. Name (OOTest is
Unnamed in the module of loader com. Sun. View javac. The launcher. The Main $MemoryClassLoader @ 365 c30cc; Student48 is in unnamed mod
Ule of loader 'app')
The at OOTest. Main (OOTest. Java: 5)

CodePudding user response:

Package com. Ar;

Public class Student48 {
//name
String name;
//student number
Int no;
//gender
Boolean sex;
Public the static class OOTest
{
Public static void main ( String [] args {
)Student48 s=new Student48 ();
S.n ame="yuehan";
S.n o=48;
S.s ex=false;
System. The out. Println (s.n ame);
System. The out. Println (s.n o);
System. The out. Println (s.s ex);

}
}

}

CodePudding user response:

The
refer to the original poster YHxiaobai response:
Exception in the thread "is the main" Java. Lang. IllegalAccessError: class OOTest tried to access the field Student48. Name (OOTest is
Unnamed in the module of loader com. Sun. View javac. The launcher. The Main $MemoryClassLoader @ 365 c30cc; Student48 is in unnamed mod
Ule of loader 'app')
The at OOTest. Main (OOTest. Java: 5)


The first time I saw such written procedures, do not conform to the specifications, generally is the main method is given priority to, also please pay attention to the naming conventions,

 
Public class Ootest {
Public static void main (String [] args) {
Student48 s=new Student48 ();
S.n ame="yuehan";
S.n o=48;
S.s ex=false;
System. The out. Println (s.n ame);
System. The out. Println (s.n o);
System. The out. Println (s.s ex);

}
}
The class Student48 {
//name
String name;
//student number
Int no;
//gender
Boolean sex;
}

CodePudding user response:

Package com. Ar;
Public class Student48
{
//name
String name;
//student number
Int no;
//gender
Boolean sex;
//student computer
//Computer student;


}
Public class OoTest {
Public static void main (String [] args) {
Student48 s=new Student48 ();
S.n ame="yuehan";
S.n o=48;
S.s ex=false;
System. The out. Println (s.n ame);
System. The out. Println (s.n o);
System. The out. Println (s.s ex);
}
}
The Exception in the thread "main" Java. Lang. IllegalAccessError: class OoTest tried to access the field Student48. Name (OoTest is
Unnamed in the module of loader com. Sun. View javac. The launcher. The Main $2 bbaf4f0 MemoryClassLoader @; Student48 is in unnamed mod
Ule of loader 'app')
The at OoTest. Main (OoTest. Java: 4)
Or I can't
These are the two file is not in the same file

CodePudding user response:

Student48 variables with the public

CodePudding user response:

refer to the second floor qq_39936465 response:
Quote: refer to the original poster YHxiaobai response:

The Exception in the thread "main" Java. Lang. IllegalAccessError: class OOTest tried to access the field Student48. Name (OOTest is
Unnamed in the module of loader com. Sun. View javac. The launcher. The Main $MemoryClassLoader @ 365 c30cc; Student48 is in unnamed mod
Ule of loader 'app')
The at OOTest. Main (OOTest. Java: 5)


The first time I saw such written procedures, do not conform to the specifications, generally is the main method is given priority to, also please pay attention to the naming conventions,

 
Public class Ootest {
Public static void main (String [] args) {
Student48 s=new Student48 ();
S.n ame="yuehan";
S.n o=48;
S.s ex=false;
System. The out. Println (s.n ame);
System. The out. Println (s.n o);
System. The out. Println (s.s ex);

}
}
The class Student48 {
//name
String name;
//student number
Int no;
//gender
Boolean sex;
}

Thank you, also help me to solve the problem,

CodePudding user response:

The public to write more

CodePudding user response:

The
reference 3 floor YHxiaobai response:
still not
These are the two file is not in the same file


You two file if not in a package here, variable called need add public

The public protect private keyword to master these permissions, this is the foundation,
  • Related