public class Day29 {


// private: a private permission modifier that can only be used in this class
// Other classes that you want to use can only be accessed through get and set methods
		
	private String name;
	private String ID;
	private int age;

	
	
// Alt+Shift+s brings up the get and set methods
// get is the value and set is the assignment
	public String getName(a) {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getID(a) {
		return ID;
	}
	public void setID(String iD) {
		ID = iD;
	}

	public int getAge(a) {
		return age;
	}
	
	public void setAge(int age) {
		this.age = age; }}Copy the code

test


public class Day29_Test {

	public static void main(String[] args) {
	Day29 q1 = new Day29();
// the set method can store values
	q1.setName("Wolf");
	q1.setAge(34);
	
// The get method is callableSystem.out.println(q1.getAge()); String name = q1.getName(); System.out.println(name); }}Copy the code