Im trying to create a script that reverses the case of all characters of an argument from the command line:
This is what i got:
But im getting this:
ChangeCase.java :15: char cannot be dereferenced
tempCharUp = tempCharacter.t oUpperCase();
^
ChangeCase.java :16: char cannot be dereferenced
tempCharDown = tempCharacter.t oLowerCase();
^
ChangeCase.java :17: char cannot be dereferenced
if (tempCharacter. equals(tempChar Up)){
^
3 errors
Any sugestions please, im quite new to java.
Regards in advance.
This is what i got:
Code:
public class ChangeCase {
public static void main (String args[]) {
String tempString;
char tempCharacter;
char tempCharUp;
char tempCharDown;
for (int i=0 ; i < args.length ; i++){
tempString = args[i];
tempCharacter = tempString.charAt(i);
tempCharUp = tempCharacter.toUpperCase();
tempCharDown = tempCharacter.toLowerCase();
if (tempCharacter.equals(tempCharUp)){
tempCharacter = tempCharDown;
System.out.println (tempCharacter);
}
else {
tempCharacter = tempCharUp;
System.out.println (tempCharacter);
}
}
}
}
ChangeCase.java :15: char cannot be dereferenced
tempCharUp = tempCharacter.t oUpperCase();
^
ChangeCase.java :16: char cannot be dereferenced
tempCharDown = tempCharacter.t oLowerCase();
^
ChangeCase.java :17: char cannot be dereferenced
if (tempCharacter. equals(tempChar Up)){
^
3 errors
Any sugestions please, im quite new to java.
Regards in advance.
Comment