// SuccessfulSwap.java
public class SuccessfulSwap {
public static void main(String[] args)
{
String[] text = new String[] {" HELLO", " EVERYONE"};
System.out.println("Outside swap, before: "
+ text[0] + text[1]);
swap(text, 0, 1);
System.out.println("Outside swap, after: "
+ text[0] + text[1]);
} // method main
public static void swap(String[] s, int index1, int index2)
{
System.out.println("Inside swap, beginning: "
+ s[index1] + s[index2]);
String temp = s[index1];
s[index1] = s[index2];
s[index2] = temp;
System.out.println("Inside swap, end: "
+ s[index1] + s[index2]);
} // method swap
} // class SuccessfulSwap