2005-10-03

Display1.7

package yusj;
public class yusj
{
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("012344567890123456789012");
System.out.println(sentence);
System.out.println("The word \"hate\" starts at index " + position);
sentence=sentence.substring(0, position) + "adore" + ending;
System.out.println("The changed string is:");
System.out.println(sentence);

}
}

012344567890123456789012

I hate text processing!

The word "hate" starts at index 2

The changed string is:

I adore text processing!

0 Comments:

張貼留言

<< Home