JAVA

星期一, 三月 06, 2006

Display 1.7

package aaa;


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


程式結果
I hate text processing!

The world"hate"starts at index2

The changed string is:

I adore text processing!

0 Comments:

发表评论

<< Home