Java Reference
In-Depth Information
+ public static native double sqrt(double a);
+ public static native double tan(double a);
+ public static double toDegrees(double angrad);
+ public static double toRadians(double angdeg);
}
Runtime and System
Runtime and System provide access to the Java Virtual Machine (JVM) and system-wide resources.
These two classes are greatly reduced from their J2SE counterparts, so much so that it makes
sense to reproduce their entire public API here. First, let's take a look at Runtime :
public class Runtime
extends java.lang.Object {
// Static methods
public static Runtime getRuntime();
// Methods
public void exit(int status);
public long freeMemory();
public void gc();
public long totalMemory();
}
To get the single Runtime instance, call getRuntime() . You can tell the JVM to run its garbage
collector by calling gc() . On MIDP, if you try to call exit() , a SecurityException will be thrown;
the application life cycle is managed entirely through the methods of the MIDlet class. The
other two methods, totalMemory() and freeMemory() , allow you to examine the amount of
memory that is available for your application's data.
Note that Runtime does not support running external processes with the exec() method.
MIDlets cannot step outside the bounds of the JVM.
System provides static methods for performing various common tasks:
public final class System
extends java.lang.Object {
// Constants
public static final PrintStream err;
public static final PrintStream out;
// Static methods
public static void arraycopy(Object src, int src_position,
Object dst, int dst_position, int length);
public static long currentTimeMillis();
public static void exit(int status);
public static void gc();
public static String getProperty(String key);
public static int identityHashCode(Object x);
}
Search WWH ::




Custom Search