1、 class B{ int x=100,y; public void setX(int x){this.x+=x;} public void setY(int y){ y+=y;} public
答案:2 悬赏:20 手机版
解决时间 2021-02-10 03:11
- 提问者网友:愿为果
- 2021-02-09 11:16
1、 class B{ int x=100,y; public void setX(int x){this.x+=x;} public void setY(int y){ y+=y;} public
最佳答案
- 五星知识达人网友:孤老序
- 2021-02-09 11:43
class B{
int x=100,y; //定义了两个变量x,y,并且x的初始值设为100
public void setX(int x){//定义了两个方法setX(),setY(),用来设置x,y的值,方法体是用传入的参数加给自身x,y
this.x+=x;}
public void setY(int y){
this.y+=y;}
}
你的y+=y;这个语句有问题,要指明是哪个y,照你写的,两个都是形参y
int x=100,y; //定义了两个变量x,y,并且x的初始值设为100
public void setX(int x){//定义了两个方法setX(),setY(),用来设置x,y的值,方法体是用传入的参数加给自身x,y
this.x+=x;}
public void setY(int y){
this.y+=y;}
}
你的y+=y;这个语句有问题,要指明是哪个y,照你写的,两个都是形参y
全部回答
- 1楼网友:西风乍起
- 2021-02-09 13:09
class B{ int x=100,y;
public void setX(int x)
{this.x+=x;} //你的代码阅读性差,要帮你排版才能看,this.x=this.x+x;
其中,this.x是指new出来对象中的成员变量x,将局部变量的x即 set(int x)中的x传入方法体内运行“setX(int x)
{this.x=this.x+x}”
同理下面也是,//怎么代码多一个不完整的"public "
public void setX(int x)
{this.x+=x;} //你的代码阅读性差,要帮你排版才能看,this.x=this.x+x;
其中,this.x是指new出来对象中的成员变量x,将局部变量的x即 set(int x)中的x传入方法体内运行“setX(int x)
{this.x=this.x+x}”
同理下面也是,//怎么代码多一个不完整的"public "
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯