Lab 10-03-2005
Project 5 of Chap. 1
public class untitled3
{
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);
}
}

Display 1.7 of Chap. 1
public class untitled3
{
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);
}
}
public class untitled3
{
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);
}
}

Display 1.7 of Chap. 1
public class untitled3
{
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);
}
}


0 Comments:
張貼留言
<< Home