Methods provided by object class in java
java.lang.Object is the base class of all the classes in java.
Object class provides number of methods that can be used by any class in java.
Some of the methods provided by Object class are:
-
getClass()
-
hashCode()
-
equals(Object o)
-
toString()
-
finalize()
-
clone()
-
wait()
-
notify()
-
notifyAll()
Lets see few examples
Given below is an example which invokes getClass() and hashCode() method on class instance.
public class TIHDemo {
public static void main(String[] args) {
TIHDemo t = new TIHDemo();
System.out.println(t.getClass());
System.out.println(t.hashCode());
}
}
OUTPUT
class TIHDemo
366712642
Would you like to see your article here on tutorialsinhand.
Join
Write4Us program by tutorialsinhand.com
About the Author
Sonu Pandit
Technology geek, loves to write and share knowledge with the world. Having 10+ years of IT experience. B.Tech in Computer Science & Engineering
Page Views :
Published Date :
Aug 22,2020