Examples:
java.lang.Character (implements Serializable, Comparable). Character is a wrapper for a char. Useful e.g. when processing a character input from stdin or from gnu.getopt. Characters can be converted to strings using toString().
java.lang.System (extends Object). This fundamental class contains sytem-wide operations that act on the currently running virtual machine.
- Exit the VM. exit(statusCode) terminates the VM. A value other than zero indicates abnormal termination
- Bring in code from a shared library. static void load(String filename), static void loadLibrary(String libname)
- Garbage collect. System.gc() prompts the VM to run the garbage collector.
- Reference std input, stderr and stdout. This is done via the static PrintStream fields System.in, System.err and System.out
- Restrict sensitive operations. This can be done by creating a SecurityManager and calling setSecurityManager on the System class.
java.lang.System is the moral equivalent of java.lang.Runtime; both classes facilitate interaction with the currently running VM. Many methods on System e.g. System.gc, can also be called on the Runtime class, e.g. Runtime.gc.
No comments:
Post a Comment