在模块中直接新建一个类
在模块中新建一个包:
封装模块下的 Main类:
import com.bluelesson.Student;
/**
* Created on 2018/1/9.
*/
public class Main {
public static void main(String[] args) {
Student student = new Student();
student.nNum2=20;
}
}
封装模块下的com.bluelesson包中的Student类
package com.bluelesson;
/**
* Created on 2018/1/9.
*/
public class Student {
int nNum1;
public int nNum2;
private int nNum3;
protected int nNum4;
}
封装模块下的com.bluelesson包中Te类
package com.bluelesson;
/**
* Created on 2018/1/9.
*/
public class Te {
public void Test(){
Student student = new Student();
student.nNum1 =10;//默认的
student.nNum2 =10;//公有的
student.nNum4=10;//保护的
}
}