-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringexample.java
More file actions
130 lines (108 loc) · 3.87 KB
/
stringexample.java
File metadata and controls
130 lines (108 loc) · 3.87 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package string;
public class stringexample{
public static void main(String[] args) {
// StringBuffer sb = new StringBuffer("hello");
// APPEND METHOD :
// StringBuffer sb = new StringBuffer("adi");
// sb.append("tya");
// INSERT METHOD
// StringBuffer sb = new StringBuffer("Intelligent Person");
// sb.insert(11,"Young");
// DELETE METHOD
// StringBuffer sb = new StringBuffer("University");
// sb.delete(0,3);
// REPLACE METHOD
// StringBuffer sb = new StringBuffer("High Cost");
// sb.replace(0,4,"Low");
// REVERSE METHOD
// StringBuffer sb = new StringBuffer("abc");
// sb.reverse();
// LENGTH METHOD
// StringBuffer sb = new StringBuffer("hello");
// int len;
// len = sb.length();
// System.out.println(len);
// CHARAT() METHOD
// String s = "window";
// char ch;
// ch = s.charAt(2);
// System.out.println("Character is : "+ ch);
// COMPARETO() METHOD
// String s1 = "box", s2 = "BOX";
// int a;
// a = s1.compareTo(s2);
// System.out.println(a);
// COMPARETOIGNORECASE() METHOD
// String s1 = "box", s2 = "BOX";
// int a;
// a = s1.compareToIgnoreCase(s2);
// System.out.println(a);
// CONCATENATION METHOD
// String s1 = "re", s2 = "think";
// String a;
// a = s1.concat(s2);
// System.out.println(a);
// String s1 = "re", s2 = "think", s3 = "ing";
// int a = 2;
// String result;
// result = s1.concat(s2);
// result += s3;
// result += a;
// System.out.println(result);
// EQUAL() METHOD
// String s1 = "hello";
// String s2 = "world";
// String s3 = "Hello";
// System.out.println(s1.equals(s2));
// System.out.println(s1.equals(s3));
// System.out.println("Hello".equals(s3));
// EQUALIGNORECASE() METHOD
// String s1 = "Hello", s2 = "hello", s3 = "HELLO", s4 = "Hello";
// System.out.println(s1.equalsIgnoreCase(s2));
// System.out.println(s1.equalsIgnoreCase(s3));
// System.out.println(s1.equalsIgnoreCase(s4));
// System.out.println(s1.equals(s2));
// System.out.println(s1.equals(s4));
// GETCHAR() METHOD
// String a ="batman";
// char arr[] = new char [20];
// a.getChars(3, 6, arr, 0);
// System.out.println(arr);
// SPLIT METHOD
// String str = "This is a java program";
// String s[];
// s = str.split(" ");
// for(int i = 0;i < s.length; i++)
// System.out.println(s[i]);
// String s1 = "Hello";
// String s2 = new String("Hello");
// if(s1.equals(s2)){
// System.out.println("Both string are same");
// }
// else{
// System.out.println("String are not same");
// }
// SUBSTRING METHOD
// String word = "television";
// String subs = word.substring(2,5);
// System.out.println(subs);
// String word = "television";
// String subs = word.substring(2);
// System.out.println(subs);
// TOLOWERCASE() METHOD
// String s1 = "Hello", s2 = "hello", s3 = "HELLO";
// System.out.println(s1.toLowerCase());
// s1 = s3.toLowerCase();
// System.out.println(s1);
// TOUPPERCASE() METHOD
// String s1 = "Hello", s2 = "hello", s3 = "HELLO";
// System.out.println(s1.toUpperCase());
// s1 = s3.toUpperCase();
// System.out.println(s1);
// TRIM() METHOD
// String word =" Hello world ";
// String s;
// s = word.trim();
// System.out.println("Trimmed string : "+ s);
}
}