java.lang
Package
java.lang is automatically imported into all programs. It contains classes
and interfaces that are fundamental to virtually all of Java programming. It is
Java’s most widely used package.
java.lang includes the following classes:
Boolea
|
Byte
|
ThreadGroup
|
|
Long
|
StrictMath
|
RuntimePermission
|
|
StackTraceElement
|
Object
|
Process
|
|
Math
|
StringBuffer
|
Runtime
|
|
Number String
|
Compiler
|
ThreadLocal (Java 2)
|
|
Character
|
Double
|
SecurityManager
|
|
Class
|
Float
|
Integer
|
|
ClassLoader
|
Thread
|
Short
|
|
|
Throwable
|
Void
|
java.lang
also defines the following interfaces:
Cloneable Comparable Runnable CharSequence
There is one special class, Object,
defined by Java. All other classes are subclasses of Object. That is, Object is a superclass of all other classes. This means
that a reference variable of type Object
can refer to an object of
any other class.
Since arrays are implemented as classes, a variable of type Object can also refer to any array.
Object defines the following methods, which means that they are
available in every object.
Object
clone( ) throws CloneNotSupportedException
Creates a new object that is the same as the invoking object.
boolean
equals(Object object)
Returns true if the invoking object is equivalent to object.
void
finalize( ) throws Throwable
Default finalize(
) method. This is usually
overridden by subclasses.
final
Class getClass( )
Obtains a Class object that describes the invoking object.
int
hashCode( )
Returns the hash code associated with the invoking object.
final
void notify( )
Resumes execution of a thread waiting on the invoking object.
final
void notifyAll( )
Resumes execution of all threads waiting on the invoking object.
String
toString( )
Returns a string that describes the object.
final
void wait( )throws InterruptedException
Waits on another thread of execution.
final
void wait(long milliseconds) throws
InterruptedException
Waits up to the specified number of milliseconds on
another thread of execution.
final
void wait(long milliseconds,int nanoseconds) throws
InterruptedException
Waits up to the specified number of milliseconds plus nanoseconds on another thread of execution
The clone( ) method generates a duplicate copy of the object
on which it is called. Only classes that implement the Cloneable interface can be cloned. The Cloneable interface
defines no members. It is used to indicate that a class allows a bitwise copy
of an object (that is, a clone) to be made. If you try to call clone( ) on a class that does not implement Cloneable, a CloneNotSupportedException is thrown. When a clone is made, the constructor
for the object being cloned is not
called. A clone is simply an
exact copy of the original.Cloning is a potentially dangerous action, because
it can cause unintended side effects.
Posted By : Ruchita Pandya
No comments:
Post a Comment