标签:output nat tput str color ret pre new valueof
public class Swap2 { public static void Swap2 (IDemo a, IDemo b) { int temp = a.i; a.i = b.i; b.i = temp; } public static void main (String args []) { IDemo a, b; a = new IDemo ( 10 ); b = new IDemo ( 20 ); System.out.println ( "a is " + a); System.out.println ( "b is " + b); Swap2.Swap2 (a, b); System.out.println ( "a is " + a); System.out.println ( "b is " + b); } } class IDemo { protected int i; public IDemo(int _i) { i=_i; } public String toString() { return String.valueOf(i); } }
---------- java ---------- a is 10 b is 20 a is 20 b is 10 Output completed (1 sec consumed) - Normal Termination
标签:output nat tput str color ret pre new valueof
原文地址:http://www.cnblogs.com/sky20080101/p/6855648.html