Pages

java.lang Package

In this tutorial I'll show you the main classes and methods in java.lang package.

Here are the main classes in java.lang package.

  • classses
    • Boolean
    • Byte
    • Character
    • Character.Subset
    • Character.UnicodeBlock
    • Class<T>
    • ClassLoader
    • Compiler
    • Double
    • Enum<E extends Enum<E>>
    • Float
    • InheritableThreadLocal<T>
    • Integer
    • Long
    • Math
    • Number
    • Object
    • Package
    • Process
    • ProcessBuilder
    • Runtime
    • RuntimePermission
    • SecurityManager
    • Short
    • StackTraceElement
    • StrictMath
    • String
    • StringBuffer
    • StringBuilder
    • System
    • Thread
    • ThreadGroup
    • ThreadLocal<T>
    • Throwable
    • Void
  • Interfaces
    • Appendable
    • CharSequence
    • Cloneable
    • Comparable<T>
    • Iteratable<T>
    • Readable
    • Runnable
    • Thread.UncaughtExceptionHandler

First we take a look at the most important class Object class. Object class has several methods. Some methods are very useful. Here are the methods in Object class.
  • protected Object clone()
  • boolean equals(Object obj)
  • protected void finalize()
  • Class<?> getClass()
  • int hashCode()
  • void notify()
  • void notifyAll()
  • String toString()
  • void wait()
  • void wait(long timeout)
  • void wait(long timeout, int nanos)
Now We take a look at some examples of these methods.

  • protected void finalize() throws Throwable
    • Called by garbage collector. (System.gc)
    • We can override this method to cleanup some resources
    • Not invoked more than once by a virtual machine for given object.

1 comment: