<> example : Define a student class and encapsulate it

<> Quick encapsulation after definition

Right click to select cource >> go to >> generate getters and setters…

The code is as follows :
package inherit ; public class Student { private String name ; private int age ;
private String college ; private String depart ; public Student (){} public
Student (String name , int age , String college , String depart) {
this.setName(name); this.setAge(age); this.setCollege(college);
this.setDepart(depart); } public void setName(String name){ this.name = name; }
public void setAge(int age) { this.age = age ; } public void setCollege(String
college){ this.college = college ; } public void setDepart(String depart){
this.depart = depart ; } public String getName(){ return this.name ; } public
int getAge(){ return this.age ; } public String getCollege(){ return
this.college ; } public String getDepart(){ return this.depart; } public String
getInfo(){ return " Student information is as follows :" + "\n" + " full name :" + this.getName() + "\n" + " Age :" +
this.getAge() + "\n" + " school :" + this.getCollege() + "\n" + " college :" +
this.getDepart(); } } class test1{ public static void main (String args[]){
Student stu1 = new Student(" Zhang San " , 22 , "shu" , "computer science and
techololege") ; System.out.println(stu1.getInfo()); } }

Technology
©2019-2020 Toolsou All rights reserved,
c Language implementation 《 Student management system 》 No hole is the future of mobile phone ? There are still many problems to be solved Junior , A little sense , Just for mutual encouragement How to use Vue Used in Echarts Visual Library The 11th Blue Bridge Cup Java The second provincial competition B Group part Python- be based on OpenCV Contour fill for flooding algorithm hole filling 【C#】 The realization of student achievement information management system List Common interview questions in the collection and simple ideas China Mobile Science Popularization : Why do mobile networks call “ Cellular mobile network ”【Golang Basic series 10 】Go language On conditional sentences if