My other sites

Latest News

New Summer Look :)










The java.lang package

 

java.lang.Object

java.lang.Class

java.lang.String

java.lang.StringBuffer

Wrapper Classes

java.lang.Math

java.lang.Runtime

java.lang.Process

java.lang.System

 


 

java.lang.Object

 

- Objects of the class Object are the root of the class hierarchy

public class Object {
   // Constructor
   public Object();
   public final Class getClass();
   public int hashCode();
   public boolean equals(Object obj);
   protected Object clone();
   public String toString();
   protected void finalize(); 
   // Thread methods, 
   public final void notify()
   public final void notifyAll()
   public final void wait(long)
}

- getClass() returns the object of type Class that represents the untime
class of the object

- hashCode() returns a unique hash value

- equals() checks equality of objects

- clone() makes a shallow copy

- toString() returns a string representation

- finalize() is called by the garbage collector


java.lang.Class

public final class Class extends Object implements Serializable {
   public static Class forName(String)
   public Object newInstance()
   public boolean isInstance(Object)
   ... 
}
 
- Instances represent classes and interfaces in a running application

- Created automatically by the VM or by a call to the classloader

- No public constructor

- Needed for writing systems that use reflection

- forName returns the class object associated with the class with the given string name
 


java.lang.String


- Character strings
- all string literals ("abc")
- Constant

Methods for:
- examining individual characters
- comparing strings
- searching strings
- extracting substrings
- copying
- concatenating
- translation to uppercase or lowercase


java.lang.StringBuffer

  A string buffer implements a mutable sequence of characters

methods : append() and insert()

The binary concatenation operator +
x = "a" + 4 + "c"

equals x = newStringBuffer().append("a"). append(4).append("c").toString();

How does this affect the passing by reference of Strings?


Wrapper Classes


- Needed for using datatypes on arrays of Objects, Lists etc.
- Contain convertion methods.
- Wrapper Classes:

Boolean
Character
Double
Float
Integer
Long
Number
Byte
Short

 

 

java.lang.Math

- Basic numerical operations

- exponentials

- logarithms

- square roots

- trigonometrics

-Equivalent to C's <math.h>
Examples:

abs

pow, sqrt

log, exp

sin, cos, tan, asin, acos, atan

floor, ceil, round

max, min, random

 

java.lang.Runtime

- There is a single instance of Runtime

- It allows the application to interface with its environment

- The current Runtime can be obtained from the static getRuntime() method

- An application cannot create its own instance of this class

- The most used methods: exec, exit, load

 

java.lang.Process

 

- The Runtime exec methods return a Process object

- Controls the process and obtain information about it

- The subprocess is not killed when there are no more references to the Process object, but rather the subprocess continues executing asynchronously

public abstract int waitFor()
public abstract int exitValue()
public abstract void destroy()
public abstract OutputStream getOutputStream()
public abstract InputStream getInputStream()
public abstract InputStream getErrorStream()

 

java.lang.System


A number of useful class fields and methods

Always available (static)

Cannot be instantiated

Access to externally defined properties

Streams in, out, err

void arraycopy(Object, int, Object, int, int)
Properties getProperties()
void setProperties(Properties)
String getProperty(String)
String getProperty(String, String)
void exit(int)
void load(String)
void loadLibrary(String) Streams