星期一, 10月 03, 2005

display1.7

display1.7程式碼

public class StringProcess
{
public static void main(String[] args)
{
String sentence = " I hate text processing!";
int position =sentence.indexOf(" hate ");
String ending=
sentence.substring(position + " hate ".length() );
System.out.println("01234567890123456789012");
System.out.println(sentence);
System.out.println(" The word \" hate \" atarts at index "+position);
sentence=sentence.substring(0,position) + "adore" +ending;

System.out.println("The changed string is: ");
System.out.println(sentence);
}
}

0 Comments:

張貼留言

<< Home