任何数据类型都能作为方法的参数,传递给方法
类代码
public class Phone {
String brand;
double price;
String color;
public void call(String who){
System.out.println("给"+who+"打电话");
}
public void sendMessage(){
System.out.println("群发短信");
}
}
对象代码
public static void main(String[] args) {
Phone one = new Phone();
one.brand="苹果";
one.price=8888.88;
one.color="炫彩金";
method(one);
}
public static void method(Phone Param){
System.out.println(Param.brand);
System.out.println(Param.price);
System.out.println(Param.color);
}