본문 바로가기

<Main>200

자바(JAVA) - 대표적인 String 메소드, / 대문자--> 소문자/ toLowerCase( ) /소문자 --> 대문자/ toUpperCase( ) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 //(문자열)소문자 --> 대문자 String str10 = "abcDEF"; String upStr = str10.toUpperCase(); System.out.println("str10 = " + upStr); //ABCDF 출력 //(문자열)대문자--> 소문자 String lowStr = str10.toLowerCase(); System.out.println(lowStr); //abcdf 출력 Colored by Color Scripter cs 대문자--> 소문자 toLowerCase( ) 소문자 --> 대문자 toUpperCase( ) 2021. 1. 25.
자바(JAVA) - 대표적인 String 메소드, / 문자열을 자른다 .split/ 문자열의 범위로 자르는 함수 substring 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 29 30 31 32 33 34 35 36 37 // 문자열을 자른다. // split /* aaaa-bbbb-ccccc aaaa bbb ccccc// 이것만 때서 사용하고 싶을때! 홍길동-24-2001/12/23-서울시 안신 - 21-2001/10/11 */ String str8 = "홍길동-24-2001/12/23-서울시-181.1"; String split[] =str8.split("-"); System.out.println(split.length); // 5 출력 System.out.println(split[0]); // 홍길동 System.out.println(s.. 2021. 1. 25.
자바(JAVA) : 대표적인 String 메소드, / 수정 .replace 1 2 3 4 5 6 7 8 9 10 11 12 13 14 // 수정 // replace String str7 = "A*B*C*D"; String reStr = str7.replace("*", ""); //ABCD 출력 //new 엔 바꾸고 싶은 것 넣기 System.out.println(reStr); String str88 = "나는 반드시 성공할 수 있 습니다."; String reStr2 = str88.replace(" ", " "); System.out.println(reStr2); // 한칸 이기도 가능하다. Colored by Color Scripter cs 변수. replace( old char, new char); .replace( 변경하고싶은내용 , 변경할 내용); 2021. 1. 25.
JAVA(자바) : 대표적인 String 메소드, / 문자열 길이를 알수있는 함수 .length 변수. length( ); 문자열의 길이를 알 수 있는 함수 1 2 3 4 5 6 7 8 9 10 11 // 문자열의 길이 알 수 있는 함수 // length // 배열 array.length // 문자열 str.length() ..들어가는 값 x String str6 = "abcdeabcde"; int len = str6.length(); System.out.println("str6의 문자열의 길이 = " + len); cs Colored by Color Scripter cs ▶ 출력 str6의 문자열의 길이 = 10 2021. 1. 25.