Project5
package project5;
public class project5
{
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("The line of text to be changed is");
System.out.println(sentence);
sentence=sentence.substring(0, position) + "love" + ending;
System.out.println("I have rephrased that line to read:");
System.out.println(sentence);
}
}
The line of text to be changed is
I hate you.
I have rephrased that line to read:
I love you.
public class project5
{
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("The line of text to be changed is");
System.out.println(sentence);
sentence=sentence.substring(0, position) + "love" + ending;
System.out.println("I have rephrased that line to read:");
System.out.println(sentence);
}
}
The line of text to be changed is
I hate you.
I have rephrased that line to read:
I love you.
0 Comments:
張貼留言
<< Home