Skip to content

Commit 660cc93

Browse files
authored
Add files via upload
1 parent 713ef4b commit 660cc93

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

classstr.java

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

0 commit comments

Comments
 (0)