-
자바 알파벳과 아스키코드Java 2023. 8. 13. 15:31
자바 알파벳과 아스키코드
- char 배열을 활용한 알파벳 출력
public static void main(String[] args) { char[] abc=new char[26]; // 대문자 for(int i=0; i<abc.length; i++) { abc[i]=(char)(i+65); } for(int i=0; i<abc.length; i++) { System.out.print(abc[i]+" "); } // 소문자 for(int i=0; i<abc.length; i++) { abc[i]=(char)(i+97); } for(int i=0; i<abc.length; i++) { System.out.print(abc[i]+" "); } }- 문자열 영단어를 알파벳으로 배열에 담아 사용하기
String temp = "developer"; String tempArr = temp.split(""); char[] tempCharArr = temp.toCharArray();알파벳과 숫자의 전환
- 알파벳 -> 숫자
char temp = 'a'; int tempIdx = Integer.valueOf(temp); // 97- 숫자 -> 알파벳
int tempIdx = 97; char temp = (char)tempIdx; // a출처
https://m.blog.naver.com/zzang9ha/221808985304
https://adjh54.tistory.com/189'Java' 카테고리의 다른 글
자바 Garbage Collection에 대한 개념 (0) 2023.10.08 자바 JVM의 런타임 데이터 영역 (Runtime Data Area) 자세한 구조 (0) 2023.10.08 자바 데이터 타입 (0) 2023.08.13 자바 예외 종류 및 Exception 처리 (0) 2023.08.13 자바 생성자(Constructor) 정리 (0) 2023.08.11