유블로그

[Java] char to int / int to char / char to str / str to char array 본문

Java

[Java] char to int / int to char / char to str / str to char array

yujeong kang 2020. 8. 19. 21:56
public class test {
	public static void main(String[] args) {
		char c = '1';
		int a = c - '0';
		System.out.println(a);	// 1
		
		int b = 2;
		char ch = (char)(b + '0');
		System.out.println(ch);	// 2
		
		c = 'a';
		String s = Character.toString(c);
		s = new Character('a').toString();
		
		String str = "abc";
		char[] arr = str.toCharArray();
		
	}
}

'Java' 카테고리의 다른 글

[Java] Priority Queue 사용법  (0) 2020.08.23
[Java] jdbc로 DB 사용하기  (0) 2020.08.20
[Java] JSON(Java Script Object Notation)  (0) 2020.08.18
[Java] Thread  (0) 2020.08.18
[Java] Concurrent vs Parallel  (0) 2020.08.18