package study;
public class Index_Study {
public static void main(String[] args) {
//검색기능
// 0 1 2 34 5 6 7 8 <= index
String str = "우리나리 대한민국";
int index = str.indexOf('국');
System.out.printf("'국'의 위치는 : %d\n", index);
index = str.indexOf("대한");
// 떠블커테션 앞에 역슬러쉬 붙이면 문자처리됨
System.out.printf("\" 대한 \"의 위치는 : %d\n", index);
}
}
'IT > 자바함수' 카테고리의 다른 글
insert() 원하는 위치에 글자 삽입 함수 (0) | 2018.04.28 |
---|---|
String.format() 객체생성 없이 쓸수 있는 Static 메소드 (0) | 2018.04.28 |
substring() 문자열을 원하는 위치에서 잘라야 하는 경우 (0) | 2018.04.28 |
Integer.parseInt() 문자를 숫자로 변형할 때 (0) | 2018.04.28 |
charAt() (0) | 2018.04.28 |