this.age = age

问题描述:

this.age = age
java 语句
1个回答 分类:综合 2014-10-10

问题解答:

我来补答
this.age是你这个类里的一个变量(实参,分配地址并且储存了的),而后面那个age是形参(通过外来传入的,只在某个method里有效)
举个例子啊:
import java.util.*;
public class example{
public static int age;
public void HowOldAreYou(int yourage){
this.age=yourage;//这就是把yourage赋值给这个类的变量age.
}
public static void main(String[]args){
Scanner s=new Scanner(System.in);
int yourage=s.nextInt();
example e=new example();
e.HowOldAreYou(yourage);
System.out.println(e.age);
}
}
懂了吗?还可以问
 
 
展开全文阅读
剩余:2000