Java Reference
In-Depth Information
Exercise 5.72 The following code fragment attempts to print out a string in uppercase letters:
public void printUpper(String s)
This code, however, does not work. Find out why, and explain. How should it be written
Exercise 5.73 Assume that we want to swap the values of two integer variables, a and b.
To do this, we write a method
public void swap(int i1, int i2)
int tmp = i1;
i1 = i2;
i2 = tmp;
Then we call this method with our a and b variables:
swap(a, b);
Are a and b swapped after this call? If you test it, you will notice that they are not! Why does
this not work? Explain in detail.
Search WWH ::

Custom Search