Class Object : Class Object « Class Definition « Java Tutorial

Home
Java Tutorial
1.Language
2.Data Type
3.Operators
4.Statement Control
5.Class Definition
6.Development
7.Reflection
8.Regular Expressions
9.Collections
10.Thread
11.File
12.Generics
13.I18N
14.Swing
15.Swing Event
16.2D Graphics
17.SWT
18.SWT 2D Graphics
19.Network
20.Database
21.Hibernate
22.JPA
23.JSP
24.JSTL
25.Servlet
26.Web Services SOA
27.EJB3
28.Spring
29.PDF
30.Email
31.J2ME
32.J2EE Application
33.XML
34.Design Pattern
35.Log
36.Security
37.Apache Common
38.Ant
39.JUnit
Java Tutorial » Class Definition » Class Object 
5.17.3.Class Object Previous/Next
  1. All the classes defined are subclasses by default.
  2. Object is a superclass of every class.
  3. The inheritance happens automatically.
  4. Your classes will inherit members from the class Object.
MethodPurpose
toString()returns a string describing the current object
equals()compares two objects
getClass()returns a Class that identifies the class of the current object.
hashCode()calculates a hashcode for an object
notify()wakes up a thread associated with the current object.
notifyAll()wakes up all threads associated with the current object.
wait()causes a thread to wait


class Dog{
  public Dog(String aType){
  }
}
public class MainClass{
  public static void main(String[] a){
    Dog d = new Dog("a");
    Class objectType = d.getClass();             
    System.out.println(objectType.getName());      
  }
}
Dog
5.17.Class Object
5.17.1.Getting java.lang.Class: Information about your object
5.17.2.Comparing Objects
5.17.3.Class Object
5.17.4.Storing a reference to the String object as type Object
5.17.5.The 'Class' class also brings the possibility of creating an object without using the new keyword.
5.17.6.Assignment with objects is a bit tricky.
5.17.7.Demonstrate Run-Time Type Information.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.