티스토리 뷰
문자열 자르기 - Split
String a = "a,b,c,d,e";
String[] arr = a.split(",");
System.out.println(Arrays.toString(arr));
[a, b, c, d, e]
특정문자 제거하기 - replace
a = a.replace("{","").replace("}","");
맨 앞의 요소 제거하기 - substring
if(a.startsWith(",")) {
a = a.substring(1);
}
String to Int
String s = "123";
int StringToInt = Integer.parseInt(a);
Int to String
int i = 123;
String IntToString = Integer.toString(i);
String index로 접근하기 - charAt
String a = "abcde";
System.out.println(a.charAt(1));
//b
int at1 = a.charAt(1);
System.out.println(at1);
//98
String at2 = a.charAt(1) + "";
System.out.println(at2);
//b
추출한 값을 int에 넣어주면 아스키값 출력
반응형
'자바' 카테고리의 다른 글
[java]Int와 Integer (0) | 2021.06.22 |
---|---|
[JAVA]not dereferenced error (0) | 2021.06.22 |
[JAVA]배열 다루기 (0) | 2021.06.20 |
[JAVA]스택 사용 (0) | 2021.06.20 |
JAVA 배열선언 및 출력 (0) | 2021.05.27 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- closure
- ios
- SWiFT
- readme ignore파일 포함한 repository
- 클로저
- New Group
- property wrapper
- xcsharedata
- palera1n
- 백준 1065번 swift
- Xcode
- django
- 파이썬
- 백준알고리즘
- 알고리즘
- sileo
- 애플 인증서
- 이분탐색
- 백준 4673 swift
- ios mvvm
- New Group Without Folder
- 프로퍼티 래퍼
- 장고
- 백준
- xcuserdata
- 애플 인증
- provisioning key
- mvvm in swiftui
- main branch
- Widget
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함