# [JAVA] I want to convert characters ...

I'm doing a competition pro and I've run out of time due to problem A, so take notes

# One character can be operated by char type

## Convert one character to the next

``````char c = 'a';
c++;
System.out.println( c ); // b
``````

## Case conversion

``````char c = 'a';
c -= 32;
System.out.println( c ); // A
``````

Convert from lowercase to uppercase -32 Uppercase to lowercase conversion is +32

## Other

If you calculate on the argument, the character code will be output, so it may be better to add one line quietly

``````char c = 'a';
System.out.println( c - 32 ); // 65
System.out.println( (char)( c - 32 ) ); //A: OK if you cast
``````

# Stumble problem

A - Next Alphabet

### Problem statement

Given a lowercase C that is not z. Output the next letter of C in alphabetical order.

### Constraint

C is a non-z lowercase letter

``````import java.util.*;

public class Main {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);
char c = in.nextLine().charAt(0);
System.out.println( ++c );

}

}
``````

Clean

``````import java.util.*;

public class Main {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);
String c = in.nextLine();
String base = "abcdefghijklmnopqrstuvwxyz";

for( int i = 0 ; i < base.length() ; i++ ){
if( c.charAt(0) == base.charAt( i ) ){
System.out.println( base.charAt( i + 1 ) );
return;
}
}

}

}

``````

？？？？？？？？？？？？？？？？？？？？？ Well, well, well, I'm not wrong It's AC