class Student {                        
    private String stuName;                           //私有变量的定义
    private int stuNo;
    private static int count = 1000;
    String getName() {
        return stuName;
    }
    void setName(String str) {
        stuName = str;
    }
    int getStu_no() {
        return stuNo;
    }
    private int numerate() {                           //私有方法，计算最新序号
        return count++;
    }
    Student(String stu_name) {
        stuName = stu_name;
        stuNo = numerate();                          //调用私有方法，设置学号
    }
    boolean isEqualTo(Student stu) {
        if (stuName == stu.stuName && stuNo == stu.stuNo)           // 同类对象访问私有变量
  return true;
        else
            return false;
    }
}
public class Example3_12{
    public static void main(String[] args) {
        Student stu1 = new Student("xiaoming");
        Student stu2 = new Student("xiaoming");
        System.out.println(stu1.isEqualTo(stu2));
        System.out.println(stu1.getName() + ":" + stu1.getStu_no());      // 间接访问私有变量
        System.out.println(stu1.getName() + ":" + stu2.getStu_no());
    }
}
