-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathstrings.java
More file actions
15 lines (13 loc) · 852 Bytes
/
strings.java
File metadata and controls
15 lines (13 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package exercises;
import java.util.Scanner;
public class strings {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String str = "Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice 'without pictures or conversation?'";
Integer index = firstSentence.indexOf(searchTerm);
Integer length = searchTerm.length();
System.out.println("Your search term first appears at index " + index + ". Your term is " + length + " characters long.");
String modifiedSentence = firstSentence.replace(searchTerm, "");
System.out.println(modifiedSentence);
}
}