ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 자바
    Data/string 2011. 8. 8. 22:05
    java.lang.String
    new 없이도 객체를 생성할 수 있는 유일한 참조 자료형
    c.f. 
    Integer refInt1;
    refInt1 = 100;

    .getBytes()
    .valueOf() // static
    주어진 객체나 기본 데이터형을 문자열로 바꾼다.
    c.f. .+()
    .copyValueOf(char data[]) // String; static
    .toCharArray() // char[]
    .split(String regex, int limit)    // String[]
    c.f. java.util.StringTokenizer

    .length()
    c.f. 배열은 .length, Collection은 .size()

    .+()

    자바 인터프리터는 모든 기본형에 대해서 내장된 문자열 변환을 가지고 있다.

    객체의 toString() 메소드를 호출하면 객체는 문자열로 변환된다.

    c.f. .valueOf()

    .concat()
    c.f. StringBuilder


    .equals()    // boolean
    두 객체의 내용이 동일한지 여부
    .equalsIgnoreCase()
    .matches(String regex)    // boolean
    .==()
    객체의 null 체크는 반드시 필요하다
    두 레퍼런스 변수가 동일한 인스턴스를 가리키는지 여부 // 동일한 포인터 값?
    .isEmpty()

    .compareTo()    // int
    .compareToIgnoreCase()

    .startsWith()    // boolean
    c.f. java.util.regex.Matcher::lookingAt()
    .endsWith()    // boolean
    .contains()    // boolean

    .indexOf(String str, int fromIndex)    // n
    .lastIndexOf()

    .substring(int beginIndex[, int endIndex])
        Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.
    .charAt()

    .trim()
    .replace()
    .replaceAll(String regex, String replacement)
    e.g. s = s.replaceAll(" {2,}", " ");    // Replace two or more spaces with a single space
    e.g. s = s.replaceAll("^ +", "");       // Replace one or more spaces at the beginning of each
        // line with no spaces
    .replaceFirst(String regex, String replacement)
    .format()
    c.f. System.out.format()
    .toUpperCase()
    .toLowerCase()


    java.util.StringTokenizer

    c.f. String::split()


    .hasMoreElements()

    .nextToken()


    StringBuilder


    java.lang.StringBuffer

    .charAt()

    .setCharAt()

    .append()

    .insert()

    .replace()

    .delete()

    .deleteCharAt()

    .setLength()

    .substring()


Designed by Tistory.