方法传对象参数 改变不了引用 懵...求大神 财富值52?
执行方法后不应该对象a ,b的指向交换吗?求指点!!!
public class Text16 {pu优艾设计网_Photoshop论坛blic static void main(String[] args) { Circle a = new Circle(1); Circle b = new Circle(2); method(a,b); System.out.println("一、a半径:"+a.radius+",b半径:"+b.radius); } public static void method(Circle x,Circle y){ Circle tmp = x; x = y; y = tmp; }} class Circle{ double radius; Circle(double x){ radius = x; } }
精彩评论