I am trying to use the "else if" function to have a second instance where if the first character of the input is, say "p", to change the full text to lower case using ".toLowerCase".
Am trying to just keep the one String, or should I need to set a second String to get this criteria to run.
Code currently is:
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Please enter a uncoded string: ");
String first = input.nextLine();
if (first.charAt(0) == 'u') {
first = first.toUpperCase();{
if (first.chatAt(0) == 'l') {
first = first.toLowerCase();
}
}
System.out.println("The decoded string is: " + first);
}
}
}
The first part works to change text to upper case using "toUpperCase" but am having trouble getting to include the second itteration to run.
Get this error message in the Console:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method chatAt(int) is undefined for the type String
Any help appreciated.
Thanks
Aucun commentaire:
Enregistrer un commentaire