public static void main(String[] args) {
char c1 = 'a';
char c2 = c1;
char c3 = ' ';
int i = c1 + 1;
c3 = (char)(c1 + 1);
c2++;
c2++;
System.out.println("i=" + i);
System.out.println("c2=" + c2);
System.out.println("c3=" + c3);
}
public static void main(String[] args) {
char c1 = 'a';
char c2 = 'a'+1;
System.out.println(c2);
}
- 피연산자에 변수가 들어가 있는 경우 자동형변환이 이루어 지지 않는다.
- 리터럴과 상수간의 연산은 에러없이 이루어진다.
public static void main(String[] args) {
char c = 'a';
for(int i=0; i<26; i++) {
System.out.print(c++);
}
System.out.println();
c = 'A';
for(int i=0; i<26; i++) {
System.out.print(c++);
}
System.out.println();
c = '0';
for(int i=0; i<10; i++) {
System.out.print(c++);
}
System.out.println();
}
- 문자형도 연산자를 이용하여 소문자/대문자간 변환을 용이하게 할 수 있다.