Step 4:

Create a copy of the app
Check02R.java and call it Check02S.java

The class
String has a service called toUpperCase(). Here is the Application Programming Interface (API) for the method.

****************

String toUpperCase()

Returns:
the String, converted to uppercase.
****************

Careful! The line in the API is not a statement; it is documentation. Although it might look like code, it isn't and don't include it in your app. Rather, the line at the top line of the API is written following a certain convention to tell you how to use the method
toUpperCase() - the line tells you that the method returns a String (the return type is listed first) and that it does not take any parameters (there is nothing between the parentheses).

Use this service to print out your user name all in uppercase. Recall you have a variable called
myName from Step 1. You should invoke the method toUpperCase() on this variable. You can store the return in another variable or print the return directly to the console.

Examples from the textbook:
  • 3ed, p52, sec 2.1.2: invoking the method getArea() on the variable r that was declared as a Rectangle
  • 2ed, p53, sec 2.1.3: invoking the method getArea() on the variable r that was declared as a Rectangle3.
  • notice that the method getArea() returns an int, whereas toUpperCase() returns a String.

In order to use the services of the
String class, you don't need to provide an import statement. String belongs to the package java.lang, which is automatically imported.

The output will look something like this:


Pasted Graphic 1