-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubString.java
More file actions
28 lines (26 loc) · 815 Bytes
/
subString.java
File metadata and controls
28 lines (26 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package nyc.c4q.fattyduck;
/**
* Created by fattyduck on 3/15/15.
*/
import java.util.Scanner;
public class subString {
public static String sString(String text, int start, int end){
String result="";
for (int i=start;i<end;i++){
result+=text.charAt(i);
}
return result;
}
public static void main(String[] args){
Scanner cow=new Scanner(System.in);
String word;
int start, end;
System.out.println("What is the word you want to use?");
word=cow.nextLine();
System.out.println("Which character do you want to start at?");
start=cow.nextInt();
System.out.println("Which character do you want to end at?");
end=cow.nextInt();
System.out.println(sString(word,start,end));
}
}