개발 블로그
6강 문자열의 표현, 문자열 다루기 본문
public class StringApp {
public static void main(String[] args) {
System.out.println("Hello World"); //String 큰따옴표, 문자열 캐릭터들이 모여 있는 것; 우린 String만 생각하면 됨! 큰따옴표만 사용!!!!
System.out.println('H'); // Character 작은 따옴표, 문자 한 글자를 표현 하는 것
System.out.println("H"); // String
System.out.println("Hello"
+ " World");
// new line 줄바꿈 문자 \n (\는 역슬러시)
System.out.println("Hello \nWorld");
// escape \를 사용해서 뒤에 따라오는 문자 표현
System.out.println("Hello \"World\""); // Hello "world" 라고 표현하고 싶을 때
}
}
6.5.문자열다루기
public class StringOperation {
public static void main(String[] args) {
System.out.println("Hello World".length()); //11 문자갯수
System.out.println("Hello, [[[name]]] ... bye.".replace("[[[name]]]", "egoing")); // 이메일 보낼 때 같은 내용이지만 상대방 이름을 계속 바꾸고 싶을 때 사용 가능
}
}
'코딩' 카테고리의 다른 글
JSP / querystring &위치 주의 (0) | 2021.12.11 |
---|---|
8강 변수 (0) | 2021.08.19 |
이클립스 cannot be resolved to a type 에러 (0) | 2021.08.19 |
생활코딩 WEB2 CSS (0) | 2021.04.21 |
생활코딩 WEB1-HTML 부록 정리 (0) | 2021.04.19 |