Code of Uppercase alphabet ‘A’ is 67 and Code of Lowercase alphabet is ‘a’ is 97. So, the offset is 32. So, to convert any Uppercase alphabet to Lowercase alphabet you have to add 32 i.e. offset to it.
Edit:
public class CaseConverter{
public static void main(String args[]){
int offset="a" - 'A';
int temp = 'X'; // or any other uppercase alphabet
System.out.println("uppercase: " + (char)temp);
temp = temp + offset;
System.out.println("lowercase: " + (char)temp);
}
}
Edit: Since your temp data type is char, then this would work
public class CaseConverter{
public static void main(String args[]){
int offset="a" - 'A';
char temp = 'X'; // or any other uppercase alphabet
System.out.println("uppercase: " + temp);
temp = (char)((int)temp + offset);
System.out.println("lowercase: " + temp);
}
}
1
solved convert uppercase letter to lowercase letter