Home > Back-end >  A operations have big ears can help me with the second picture is to write their own code, don'
A operations have big ears can help me with the second picture is to write their own code, don'

Time:10-12

CodePudding user response:

No problem,

CodePudding user response:

Student in the class attribute and private access modifiers, combined with properties of the get and set methods, welcome to join qq group (810264180) communication problems

CodePudding user response:

reference 1st floor well drainage replies:
,

Ok, I know,

CodePudding user response:

The
refer to the original poster with stranger's reply:


Lack of construction method, how do you give class variable assignment?

CodePudding user response:

reference 4 floor qq_39936465 response:
Quote: refer to the original poster with stranger's reply:



Lack of construction method, how do you give class variable assignment?

The teacher didn't speak too much

CodePudding user response:

The
reference 5 floor with stranger's reply:
the teacher didn't speak too much


The construction of the class is the basis for the writing class, the teacher didn't you say?

 
Public class Student {
//class variables encapsulated
private String id;
private String name;

//void structure
Public Student () {
super();
}
//structure with parameter
Public Student (String studentNo, String name) {
super();
This. Id=studentNo;
this.name=name;

}
//class variables set, the get method
Public String getName () {
return name;
}
Public void elegantly-named setName (String name) {
this.name=name;
}
Public String getStudentNo () {
return id;
}
Public void setStudentNo (String studentNo) {
This. Id=studentNo;
}

//use the toString method for the class variable output
@ Override
Public String toString () {
Return "{\ " id ":" + id + ", \ "name " : "+ name +"} ";
}

}

CodePudding user response:

No say, speak a little bit
  • Related