String Class Methods in Java
equalsIgnoreCase() We use this method to perform the case insensitive comparison between 2 strings. Prototype: public boolean equalsIgnoreCase(String str) Example: String str = “STEVE”; String s = “steve”; System.out.println(str.equals(s)); //output will be “true” subString() This method returns the sub string beginning at the given index to the end of the string. Prototype: public String subString(int …
String Class – Java
Objects of String class in java.lang package are immutable, which means that once we create the object, we cannot perform any changes to it. And if we do, then the program create a new object. For example: String str = new String(“Michael”); str.concate(” Jackson”); System.our.println(“String is: “+str); Output of the above code snippet is: String …
Equals() Method in Java – Object Class
In this article we will continue to explain the remaining 10 methods of Object class in java.lang package. equals(Object o) Prototype of this method is public boolean equals(Object o) We use Equals() method in order to check the equality of any 2 objects. Method equals() is meant for reference comparison or address comparison, and when …
Hashcode() and CLone() – Methods of Object Class in Java
We have already discussed about the toString() method so now we will explain the remaining 10 methods of Object class in java.lang package. 2) hashCode(): Prototype of this method is public native int hashCode() In java, JVM assigns one unique id to every object through which we can represent it in the memory. This unique …
Hashcode() and CLone() – Methods of Object Class in Java Read More »