继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

关于传参的时候不要与奔雷中的属性重名的问题

ios开发零基础入门
关注TA
已关注
手记 265
粉丝 20
获赞 110

public class MyRandom extends Random {
private int a;
private int b;
protected int m;
public int getM() {
return m;
}

protected void setM(int m) {    this.m = m;}public MyRandom() {    // TODO Auto-generated constructor stub    this(0,10);      //!}public MyRandom(int a ) {    this(0,a);}public MyRandom(int a,int d) {    a=a;     //注意这里面同名的问题。 如果这样写,就错了,系统分辨不出来。*****要改成this.a=a;this.b=b或者将形参换名字。*****    d=d;}public int nextInt() {

//      return Math.abs(super.nextInt()%b+a);
return super.nextInt(b-a+1)+a;
}

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP