package top.qaqaq.java.P221;
public class Order {
private int orderPrivate;
int orderDefault;
public int orderPublic;
private void methodPrivate() {
orderPrivate = 1;
orderDefault = 2;
orderPublic = 3;
}
void methodDefault() {
orderPrivate = 1;
orderDefault = 2;
orderPublic = 3;
}
public void methodPublic() {
orderPrivate = 1;
orderDefault = 2;
orderPublic = 3;
}
}
package top.qaqaq.java.P221;
public class OrderTest {
public static void main(String[] args) {
Order order = new Order();
order.orderDefault = 1;
order.orderPublic = 2;
//出了Order类之后,私有的结构就不可以调用了
// order.orderPrivate = 3;//The field Order.orderPrivate is not visible
order.methodDefault();
order.methodPublic();
//出了Order类之后,私有的结构就不可以调用了
// order.orderPrivate();//The method orderPrivate() is undefined for the type Order
}
}
package top.qaqaq.java.P224;
import top.qaqaq.java.P221.Order;
public class OrderTest {
public static void main(String[] args) {
Order order = new Order();
order.orderPublic = 2;
//出了Order类所属的包之后,私有的结构、缺省声明的结构就不可以调用了
// order.orderDefault = 1;
// order.orderPrivate = 3;//The field Order.orderPrivate is not visible
order.methodPublic();
//出了Order类所属的包之后,私有的结构、缺省声明的结构就不可以调用了
// order.methodDefault();
// order.orderPrivate();//The method orderPrivate() is undefined for the type Order
}
}