Java Doc for Class.java in  » 6.0-JDK-Modules » j2me » java » lang » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » java.lang 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.lang.Class

Class
final public class Class (Code)
Instances of the class Class represent classes and interfaces in a running Java application. Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions.

Class has no public constructor. Instead Class objects are constructed automatically by the Java Virtual Machine as classes are loaded.

The following example uses a Class object to print the class name of an object:

 void printClassName(Object obj) {
 System.out.println("The class of " + obj +
 " is " + obj.getClass().getName());
 }
 

version:
   12/17/01 (CLDC 1.1)
since:
   JDK1.0, CLDC 1.0




Method Summary
native public static  ClassforName(String className)
     Returns the Class object associated with the class with the given string name.
native public  StringgetName()
     Returns the fully-qualified name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String.

If this Class object represents a class of arrays, then the internal form of the name consists of the name of the element type in Java signature format, preceded by one or more "[" characters representing the depth of array nesting.

public  java.io.InputStreamgetResourceAsStream(String name)
     Finds a resource with a given name in the application's JAR file.
 voidinitialize()
    
native public  booleanisArray()
     Determines if this Class object represents an array class.
native public  booleanisAssignableFrom(Class cls)
     Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter.
native public  booleanisInstance(Object obj)
     Determines if the specified Object is assignment-compatible with the object represented by this Class.
native public  booleanisInterface()
     Determines if the specified Class object represents an interface type.
native public  ObjectnewInstance()
     Creates a new instance of a class. a newly allocated instance of the class represented by thisobject.
public  StringtoString()
     Converts the object to a string.



Method Detail
forName
native public static Class forName(String className) throws ClassNotFoundException(Code)
Returns the Class object associated with the class with the given string name. Given the fully-qualified name for a class or interface, this method attempts to locate, load and link the class.

For example, the following code fragment returns the runtime Class descriptor for the class named java.lang.Thread:

    Class t = Class.forName("java.lang.Thread")

Parameters:
  className - the fully qualified name of the desired class. the Class object for the class with thespecified name.
exception:
  ClassNotFoundException - if the class could not be found.
exception:
  Error - if the function fails for any other reason.
since:
   JDK1.0



getName
native public String getName()(Code)
Returns the fully-qualified name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String.

If this Class object represents a class of arrays, then the internal form of the name consists of the name of the element type in Java signature format, preceded by one or more "[" characters representing the depth of array nesting. Thus:

 (new Object[3]).getClass().getName()
 
returns "[Ljava.lang.Object;" and:
 (new int[3][4][5][6][7][8][9]).getClass().getName()
 
returns "[[[[[[[I". The encoding of element type names is as follows:
 B            byte
 C            char
 D            double
 F            float
 I            int
 J            long
 Lclassname;  class or interface
 S            short
 Z            boolean
 
The class or interface name classname is given in fully qualified form as shown in the example above. the fully qualified name of the class or interfacerepresented by this object.



getResourceAsStream
public java.io.InputStream getResourceAsStream(String name)(Code)
Finds a resource with a given name in the application's JAR file. This method returns null if no resource with this name is found in the application's JAR file.

The resource names can be represented in two different formats: absolute or relative.

Absolute format:

    /packagePathName/resourceName

Relative format:

    resourceName

In the absolute format, the programmer provides a fully qualified name that includes both the full path and the name of the resource inside the JAR file. In the path names, the character "/" is used as the separator.

In the relative format, the programmer provides only the name of the actual resource. Relative names are converted to absolute names by the system by prepending the resource name with the fully qualified package name of class upon which the getResourceAsStream method was called.
Parameters:
  name - name of the desired resource a java.io.InputStream object.




initialize
void initialize() throws Throwable(Code)



isArray
native public boolean isArray()(Code)
Determines if this Class object represents an array class. true if this object represents an array class;false otherwise.
since:
   JDK1.1



isAssignableFrom
native public boolean isAssignableFrom(Class cls)(Code)
Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter. It returns true if so; otherwise it returns false. If this Class object represents a primitive type, this method returns true if the specified Class parameter is exactly this Class object; otherwise it returns false.

Specifically, this method tests whether the type represented by the specified Class parameter can be converted to the type represented by this Class object via an identity conversion or via a widening reference conversion. See The Java Language Specification, sections 5.1.1 and 5.1.4 , for details.
Parameters:
  cls - the Class object to be checked the boolean value indicating whether objects of thetype cls can be assigned to objects of this class
exception:
  NullPointerException - if the specified Class parameter isnull.
since:
   JDK1.1




isInstance
native public boolean isInstance(Object obj)(Code)
Determines if the specified Object is assignment-compatible with the object represented by this Class. This method is the dynamic equivalent of the Java language instanceof operator. The method returns true if the specified Object argument is non-null and can be cast to the reference type represented by this Class object without raising a ClassCastException. It returns false otherwise.

Specifically, if this Class object represents a declared class, this method returns true if the specified Object argument is an instance of the represented class (or of any of its subclasses); it returns false otherwise. If this Class object represents an array class, this method returns true if the specified Object argument can be converted to an object of the array class by an identity conversion or by a widening reference conversion; it returns false otherwise. If this Class object represents an interface, this method returns true if the class or any superclass of the specified Object argument implements this interface; it returns false otherwise. If this Class object represents a primitive type, this method returns false.
Parameters:
  obj - the object to check true if obj is an instance of this class
since:
   JDK1.1




isInterface
native public boolean isInterface()(Code)
Determines if the specified Class object represents an interface type. true if this object represents an interface;false otherwise.



newInstance
native public Object newInstance() throws InstantiationException, IllegalAccessException(Code)
Creates a new instance of a class. a newly allocated instance of the class represented by thisobject. This is done exactly as if by a newexpression with an empty argument list.
exception:
  IllegalAccessException - if the class or initializer isnot accessible.
exception:
  InstantiationException - if an application tries toinstantiate an abstract class or an interface, or if theinstantiation fails for some other reason.
since:
   JDK1.0



toString
public String toString()(Code)
Converts the object to a string. The string representation is the string "class" or "interface", followed by a space, and then by the fully qualified name of the class in the format returned by getName. If this Class object represents a primitive type, this method returns the name of the primitive type. If this Class object represents void this method returns "void". a string representation of this class object.



Methods inherited from java.lang.Object
public boolean equals(Object obj)(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.