2008年3月10日 星期一

Homework 3-10-2008: String Processing

public class StringProcessing
{
public static void main(String[] args)
{
String original,newly,temp;
original="I hate you.";
int index;
index=original.indexOf("hate");
newly=original.substring(0,index)+"love"+original.substring(index+"hate".length(),original.length());
System.out.println("The line of text to be changed is:");
System.out.println(original);
System.out.println("I have rephrased that line to read:");
System.out.println(newly);
}
}





沒有留言: