packageorg.com;importjava.awt.*;publicclassTest{publicstaticvoidmodifyPoint(Pointpt,Integerj){pt.setLocation(5,5);j=newInteger(25);System.out.println(j);}publicstaticvoid...
package org.com;
import java.awt.*;
public class Test {
public static void modifyPoint(Point pt, Integer j) {
pt.setLocation(5,5);
j= new Integer(25);
System.out.println(j);
}
public static void main (String args[]) {
Point p = new Point(0,0);
Integer i = new Integer(10);
System.out.println(i);
System.out.println("Before modifyPoint" + p + i);
modifyPoint(p,i);
System.out.print("After modify" + p +i);
}
}
我输出的结果是:
10
Before modifyPointjava.awt.Point[x=0,y=0]10
25
After modifyjava.awt.Point[x=5,y=5]10
我想不通的是为什么i的值没有改变。???
我的想法是,Integer j = new Integer(10);
和Point pt = new Point (5,5);是一样的。
那么。请高手们告诉我;
Integer j = new Integer(10);
和int j = 10;
这样两种申明方法有什么样的区别呢?
再问下。是不是Integer 这样的类和,我们其他的那些类。还是有一定区别的呀。
希望详细点。还有,请给举个改变的例子。
小弟在此谢谢各位。
展开