Array
Array
Strings :
It will search for an string object with data NAME is string pool.
If available, str refers to that object otherwise, it creates a new object with data
NAME and refers to it.
System.out.println(str1.hashCode());
System.out.println(str2.hashCode());
------------------
System.out.println(str1.hashCode());
System.out.println(str2.hashCode());
--------------------
{
}
------------------
r1.length = 4;
r1.breadth = 4;
r2.length = 4;
r2.breadth = 4;
{
System.out.println("Equal");
}
else
System.out.println("Equal");
}
else
---------------
Object class provides equals method. This method only checks for references.
If you want to check for data, we can override the equals method and provide our own
implementation.
boolean equals(Object r)
boolean equals(Rectangle r)
}
Strings are immutable objects. Once a string object is creates, it cannot be modified.
str.toLowerCase();
It takes the string object (str), creates a new string with lowercase data of str and
returns a new string (does not modify str).
---------------------
str1.concat(str2);
System.out.println(str1);
System.out.println(str2);
Does not modify str1 OR str2. It creates a new string with data of str1 and str2 and returns
that string.
str1.indexOf(String );
0 , 3