Java Private如何使用
package com.geekeryi0730; public class Student { String name; private int age; public void setAge(int a) { if (0<a&&a<120){ age = a; }else { System.out.println("你TM给老子瞎JB输"); } } public int getAge() { return age; } public void show() { System.out.println(age + "," + name); } }
package com.geekeryi0730; public class StudentDemo { public static void main(String[] args) { Student s1 = new Student(); System.out.println(s1.getAge()); s1.setAge(999); s1.name="瓜皮"; s1.show(); } }