File tree 1 file changed +42
-0
lines changed
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ //string class can not give to permission to change their data
3
+ //in this we can only check that what character is an in which index it is present
4
+ public class norstring {
5
+
6
+ public static void main(String[] args)
7
+ {
8
+ String str1=new String("test string");
9
+ System.out.println("the str1 is = "+str1);
10
+
11
+ String str2 =new String(str1);
12
+ System.out.println("str2 is = "+str2);
13
+
14
+ String str3=new String();
15
+ System.out.println("the str3 is = "+str3);
16
+
17
+ String str4 =new String("another string");
18
+ System.out.println("the last string is = "+str4);
19
+
20
+ System.out.println("the str1 length is = "+str1.length());
21
+ System.out.println("the str2 length is = "+str2.length());
22
+ System.out.println("the str3 length is = "+str3.length());
23
+ System.out.println("the str4 length is = "+str4.length());
24
+
25
+ System.out.println("String1 character at 3 = "+str1.charAt(3));
26
+ System.out.println("String1 index of character t = "+str1.indexOf('t'));
27
+ System.out.println("string1 last index of character t = "+str1.lastIndexOf('t'));
28
+ System.out.println("the string starting from index i to lastchr = "+str1.substring(0,9));
29
+ System.out.println("string1 substring from index 1 to lastchr = "+str1.substring(0));
30
+
31
+ if(str1==str2)
32
+ {
33
+ System.out.println("euqal");
34
+ }
35
+ else
36
+ {
37
+ System.out.println("not equal");
38
+ }
39
+
40
+ System.out.println(str1.equals(str2));
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments