File tree 1 file changed +46
-0
lines changed
1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ package basicjava ;
3
+
4
+ public class String_1 {
5
+ public static void main (String [] args ) {
6
+ String s1 = "susmoy barman" ;
7
+ String s2 = new String ("susmoy barman" );
8
+
9
+ System .out .println ("s1: " +s1 );
10
+ System .out .println ("s2: " +s2 );
11
+
12
+ int len = s1 .length ();
13
+ System .out .println ("Length of s1: " +len ); // Finding the length of the string.
14
+
15
+ //Now we will find that, whether the strings are equal or not.
16
+ /*if(s1==s2){
17
+ System.out.println("Equal");
18
+ }
19
+ else{
20
+ System.out.println("Not equal"); // It will show, not equal. Because the == operator match the reference or object, not the content.
21
+ }
22
+
23
+ if(s1.equals(s2)){
24
+ System.out.println("Equal");
25
+ }
26
+ else{
27
+ System.out.println("Not equal"); // It will show equal. Because the .equals() method match the contents.
28
+ }
29
+
30
+ if(s1.contains("susmoy")){
31
+ System.out.println("True");
32
+ }
33
+ else{
34
+ System.out.println("Not True"); // It will show true. Because the .contains() method match whether the values are in the s1.
35
+ } */
36
+
37
+ if (s1 .equalsIgnoreCase ("Susmoy barman" )){
38
+ System .out .println ("Equal" );
39
+ }
40
+ else {
41
+ System .out .println ("Not equal" ); // It will show equal. Because the .equalsIgnoreCase() method will ignore the case sensitivity.
42
+ }
43
+ boolean b = s1 .isEmpty (); // It will check whether the string empty or not.
44
+ System .out .println ("b = " +b );
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments