字符串类型:“ 李明”
创建类的练习
//手机类
package it.com.qq;
public class Phone2 {
String brand;
int price;
public void prit(String brand,int price ) {
System.out.println("这个"+brand+"的价钱是"+price+"元");
}}
//测试类
package it.com.qq;
public class Phone2Demo {
public static void main(String[] args) {
Phone2 p=new Phone2();
System.out.println(p.brand );
System.out.println(p.price);
p.prit("小米",1500);
System.out.println("=====================");
p.brand="三星";
p.price=8450;
System.out.println("手机:"+p.brand+"**********价格:"+ p.price);
p.prit("小米",1500);
System.out.println("=====================");
String brand="锤子";
int price=4500;
p.prit(brand,price);
}
}