java初学者,一个小问题
publicclassPeople{intage=20;publicvoidchange(Peoplepeople){people=newPeople();people....
public class People
{
int age = 20;
public void change(People people)
{
people = new People();
people.age = 30;
}
public void change(People people)这句话是定义的一个方法还是属性?括号里面的两个people分别代表什么意思?如果在后面写一个int age = people.age那这个age等于20吗?为什么?谢谢大家 展开
{
int age = 20;
public void change(People people)
{
people = new People();
people.age = 30;
}
public void change(People people)这句话是定义的一个方法还是属性?括号里面的两个people分别代表什么意思?如果在后面写一个int age = people.age那这个age等于20吗?为什么?谢谢大家 展开
4个回答
展开全部
无奈,,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1.这是一个方法
2.public void change(People people)方法,无返回值,括号里代表传入参数(为一个People类型的对象people )
3.public void change(People people)
{
people = new People();
people.age = 30;
System.out.println("people"+people.age);//输出将为 people30
}
2.public void change(People people)方法,无返回值,括号里代表传入参数(为一个People类型的对象people )
3.public void change(People people)
{
people = new People();
people.age = 30;
System.out.println("people"+people.age);//输出将为 people30
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询