- class Nm {
- public static void main(String[] args) {
- Phone p1 = new Phone();
- p1.setName("sanxing");
- p1.setPrice(444);
- System.out.println(p1.getName() + "..." + p1.getPrice());
- Phone p2 = new Phone("三星",444);
- p2.show();
- }
- }
- class Phone {
- private String name;
- private int price;
- public Phone(){}
- public Phone(String name,int price){
- this.name = name;
- this.price = price;
-
- }
- public void setName(String name){
- this.name = name;
复制代码 |
|