passingdemo.java
来自「java 完全探索的随书源码」· Java 代码 · 共 35 行
JAVA
35 行
public class PassingDemo { public void first() { xObject o = new xObject(); // initialize an object and a primitive o.x = 5; int x = 5; // pass them to another method and then recheck their values changeThem(x, o); System.out.println(); System.out.println("Back in the original method"); System.out.println("The value of o.x is now "+o.x); System.out.println("But, The value of x is still "+x); } public void changeThem (int x, xObject o) { x = 9; o.x = 9; System.out.println("In the changeThem method"); System.out.println("The value of o.x was changed to "+o.x); System.out.println("The value of x was changed to "+x); } public static void main(String args[]) { PassingDemo myDemo = new PassingDemo(); myDemo.first(); }}class xObject { public int x;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?