package com.study.javastudy.study;

public class StringMethodExam {
    public static void main(String[] args) {
        //String str = new String("hello");
        String str = "hello";
        System.out.println(str.length()); // 5, 공백도 하나의 문자로 인식
        System.out.println(str.concat(" world")); // hello world
        System.out.println(str); // hello

        str = str.concat(" world");
        System.out.println(str); //hello world

        System.out.println(str.substring(3)); // lo world
        System.out.println(str.substring(3, 7)); // lo w, 3번부터 7이전까지, 배열은 0부터 시작
    }
}

'자바 기초' 카테고리의 다른 글

열거형(enum)  (0) 2024.01.27
변수의 scope와 static  (0) 2024.01.27
메소드 사용  (0) 2024.01.27
메소드 선언  (0) 2024.01.27
필드(field) 선언  (0) 2024.01.27

+ Recent posts