-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringUse.java
More file actions
76 lines (60 loc) · 1.52 KB
/
StringUse.java
File metadata and controls
76 lines (60 loc) · 1.52 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.util.Scanner;
public class StringUse {
public static void print(String input){
for(int i = 0; i < input.length(); i++){
System.out.println(input.charAt(i));
}
}
public static void printSubstrings(String input){
int length;
for(length = 1; length <= input.length(); length++){
for(int i = 0; i + length <= input.length(); i++){
System.out.println(input.substring(i,i + length));
}
}
}
public static void printSubstrings_2(String input){
for(int i = 0; i < input.length(); i++){
for(int j= i + 1; j <= input.length(); j++){
System.out.println(input.substring(i, j));
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
// Scanner s = new Scanner(System.in);
// String str = s.next();
//
// String arr[] = new String[10];
// for(int i = 0; i < arr.length; i++){
// System.out.println(arr[i]);
// }
printSubstrings_2("abcd");
// String str = "abcd";
// System.out.println(str.substring(0, 0));
//
// print("abcde");
// int arr[] = {1,2};
// int arr2[] = {1,2};
// if(arr == arr2){
// System.out.println("true");
// }
// else{
// System.out.println("false");
// }
//
// String str = "hello";
//
// String str2 = "hello";
//
// System.out.println(str.charAt(1));
// System.out.println(str.substring(1, 5));
// System.out.println(str.substring(4));
// System.out.println(str.length());
// System.out.println(str.concat("Hello"));
//
// if(str==str2){
// System.out.println("Equal");
//}
}
}