Category: java

Example to Overriding equals method in Java

Equals method in Java equals() is a method of Object class. Used to compare two objects or two String literals in Java. It returns boolean true or false. When we need to compare two objects we need to Override the equals() method in Java. Let’s take an example where we are going to compare two

Java tutorial || Overriding toString() method in Java.

toString() method in Java. toString() is a method of Object class. an Object is a superclass of every class in Java. toString() method returns the string representation of the object. Sometimes we need to override toString() method. so the question is that why we need to override the toString() method in Java. Let’s try to

StringBuffer class in Java.

Java StringBuffer class is a mutable class in java. It means We can change the string when we are going to use StringBuffer class in Java. StringBuffer is same as String class only the difference is it can be modified. Example: public class Main { public static void main(String args) { StringBuffer sb = new

String class in java with interview questions and answers

String class in java and its methods. A string is a class from lang package. Which is public and final class extends Object class and implements Serializable, Comparable<String>, CharSequence interface.  String Class in Java is immutable class. It means once you create an object of String class. It will not be modified read more about immutable String. Some