星期一, 3月 06, 2006

Lab0306

Display1.7



//9224205
package Lab0306;

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


----
Project1.5

package Lab0306;

public class Lab0306_2 {
public static void main(String[] args) {
String sentence = "I hate you!";
int position = sentence.indexOf("hate") ;
String ending =
sentence.substring(position+"hate".length() );
System.out.println(sentence);
System.out.println("The word \"hate\" starts at index "+position);
sentence = sentence.substring(0,position)+"love"+ending ;
System.out.println("The change string is:");
System.out.println(sentence);
}
}

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Taiwan License.