String str = "LOVE";
String strArr[]=str.toCharArray();
System.out.println(strArr[0]);
console =>
L
toCharArray...
단어를 철자별로 잘라 배열에 저장해 준다.
'Java' 카테고리의 다른 글
Java substring (0) | 2012.11.11 |
---|
WRITTEN BY
- 형때기
simple blog
,
String str = "LOVE";
String strArr[]=str.toCharArray();
System.out.println(strArr[0]);
console =>
L
toCharArray...
단어를 철자별로 잘라 배열에 저장해 준다.
Java substring (0) | 2012.11.11 |
---|
개발을 하다보면 기본에 소홀 할때가 정말 많다
Asp 까지 병행 하다 보니 가끔 한가지 언어에만 몰두하면
Asp 문법을 Jsp 에 적용 하질 않나
함수를 가져다 쓸려고 하지 않나
가끔 상이한 문법을 써놓고 왜 안되지 하면서
검색의 세계로 빠져든다
몇일던 경험해던 substring 이라는 놈..
ASP 의 left 라는 함수와 헷갈렸다
left(tmp,1) 이러질 않나 tmp.left(1) 이러질 않나
아직 운영하는 시스템의 소스만 분석 하는지라
잘 쓰지 않는 함수가 나올때면 삽질의 연속이다
이번기회에 확실히 정리해 보자 라는 마음에 블로그에 기입해 본다
뭐니 뭐니 해도 가장 빠른 법은 API 참조다
substring 메소드는 java.lang Package 의 String Class 에 있다
public String substring(int beginIndex)
Examples:
"unhappy".substring(2) returns "happy" "Harbison".substring(3) returns "bison" "emptiness".substring(9) returns "" (an empty string)
beginIndex
- the beginning index, inclusive.IndexOutOfBoundsException
- if beginIndex
is negative or larger than the length of this String
object.두개가 있네....
첫번째꺼는 파라메터가 한개가 필요한데 해당 순번 부터 마지막 문자열까지 리턴 한다
기능은 예제를 보면 잘 알것 같고..
첫번째 문자가 0부터 시작한다는 점!!!
예외는 음수이거나 문자열 갯수보다 크면 발생 하는것 까지 정리!!
public String substring(int beginIndex, int endIndex)
beginIndex
and extends to the character at index endIndex - 1
. Thus the length of the substring is endIndex-beginIndex
.Examples:
"hamburger".substring(4, 8) returns "urge" "smiles".substring(1, 5) returns "mile"
beginIndex
- the beginning index, inclusive.endIndex
- the ending index, exclusive.IndexOutOfBoundsException
- if the beginIndex
is negative, or endIndex
is larger than the length of this String
object, or beginIndex
is larger than endIndex
toCharArray (0) | 2013.08.18 |
---|