dosample0.java
来自「java实验报告书:其中包括实验代码以及说明等」· Java 代码 · 共 26 行
JAVA
26 行
class Integer //定义一个整型类
{
int i; //i定义为整型类的成员变量
}
class sample0
{
int test(Integer a) //参数a是整型类的对象
{
return ++a.i; //++a.i使实例变量i的值加1
}
}
class DoSample0
{
public static void main(String args[])
{
sample0 r=new sample0();
Integer a=new Integer();
a.i=1;
System.out.println(r.test(a)); //r.test(a)将a的地址传送给形参,
//a.i=2
System.out.println(r.test(a)); //再次调用r.test(a),a.i=3
System.out.println("This is the result:");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?