【Java开源代码栏目提醒】:网学会员在Java开源代码频道为大家收集整理了SwapTest.java提供大家参考,希望对大家有所帮助!
import school.*;
public class SwapTest
{
public static void main(String arg[])
{
Student s1 = new Student("John");
Student s2 = new Student("David");
System.out.println("Before call swap(s1, s2)");
System.out.println("s1: " + s1.getName());
System.out.println("s2: " + s2.getName());
swap(s1, s2);
System.out.println("After call swap(s1, s2)");
System.out.println("s1: " + s1.getName());
System.out.println("s2: " + s2.getName());
}
public static void swap(Student s1, Student s2)
{
Student s3;
s3=s1;
s1=s2;
s2=s3;
System.out.println("Inside swap(s1, s2)");
System.out.println("s1: " + s1.getName());
System.out.println("s2: " + s2.getName());
}
}
上一篇:
SwanCounter.java
下一篇:
简析网络电视的时代生存