더북(TheBook)

두 가지 방법을 코드로 작성해 출력하겠습니다.

package javaStudy;

public class StringMethodExam {

    public static void main(String[] args) {
        String str = "hello";
        System.out.println(str.length());
        System.out.println(str.concat(" world"));
        System.out.println(str);
        str = str.concat(" world");
        System.out.println(str);
        System.out.println(str.substring(3));
        System.out.println(str.substring(3, 6));
    }
}

 

실행결과

5
hello world
hello
hello world
lo world
lo