방치하기

노바디 본문

홍익대 Java/수업

노바디

Yi Junho 2009. 7. 27. 17:36
반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class StringTest03
{
    public static void main(String[] args)
    {
         
        int a=0;
        StringBuffer str01 =new StringBuffer();
        str01.append("You know I still love you baby And it will never change. I want nobody nobody but you!I want nobody nobody but you!난 다른 사람이 싫어, 니가 아니면 싫어.I want nobody, nobody, nobody, nobody난 싫은데 왜 날 밀어내려고 하니자꾸 내 말은 듣지 않고왜 이렇게 다른 남자에게 날 보내려 하니어떻게 이러니 ");
        System.out.println(find(a,str01));
        System.out.println(str01);
     
    }
 
     static int find(int a,StringBuffer str01)
        {
         int count=0;
         while(!(a== -1))
            {
                a=str01.indexOf("nobody",a+1);
                count++;
                if(a==-1)
                    break;
                str01.replace(a,a+6,"anybody");//else 없으면 else용도
             
            }  
        return --count;
        }
}
반응형
Comments