public class Student{
String brand;
String color;
int price;
}
//引用上面代码
public class Student2{
public static void main(String[] args){
Student stu=getSudent();
system.out.println(stu.brand);//苹果
system.out.println(stu.color);//黄色
system.out.println(stu.price);//8888
}
public static Student getStudent()
{
Student one=new Student();
one.brand="苹果";
one.color="黄色";
one.price=8888;
return one;
}
}```
使用对象类型作为方法的返回值
最新推荐文章于 2023-06-22 17:40:04 发布