trim() method and toUpperCase()
Hi there,
I am trying to figure out how to use the trim and toUpperCase Methods in Java. I looked up the methods on the internet, but when I try to implement them in my code it doesn't work. I am not sure if I need to import a class? Please see the code below ( I commented out the code for trim and toUpperCase).
Thanks ........
////////////////////code///////////////////////////
/*
* Main.java
*
* Created on February 17, 2007, 12:27 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package temp;
import java.util.*;
import java.lang.*;
/**
*
* @author dwilmes
*/
public class Main
{
public static Scanner in = new Scanner(System.in);
/** Creates a new instance of Main */
public Main()
{
}
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
char userInput = '\0';
userInput = menu(userInput);
switch (userInput)
{
case 'B':
break;
case 'R':
break;
case 'I':
break;
case 'D':
break;
default:
System.out.println("That's not A, B, or C!");
}
}
private static char menu(char userInput)
{
while(userInput != 'Q')
{
System.out.println("\n\nPlease input:\n" +
"B (Box)\n" +
"R (Rigth Triangle)\n" +
"I (Isosceles Triangle)\n" +
"D (Diamond)\n" +
"Q (Quit)");
userInput = in.nextLine().charAt(0);
//userInput = userInput.in.trim();
//userInput = userInput.in.toUpperCase();
}
return userInput;
}
}

