.Open The Predefined Classes in Java Much of the usefulness of Java comes from the packages of useful classes. objects, and functions that already exist. The class library is still evolving - see .See http://java.sun.com/j2se/1.4.2/docs/api/index.html for the current library. A complete new language and $API is expected in the summer of 2004: .See http://java.sun.com/j2se/1.5.0/docs/api/index.html and I have connected links on this page to both versions. The class library describes an $API. API::=Application Programmers Interface. In otherwords it is intended that a programmer should use these classes to do most of the work - GUI interfaces, networking, audio, and so on. More interesting is that the same code will automatically assume the look-and-feel of the client machine. If someone is using Windows 95 then they will see the usual file open dialogue. On UNIX it will look like a UNIX dialogue, and on a Mac like a Mac Dialogue. Even the form of buttons will be adjusted to what the client expects rather than what the programmer thinks is right. The following pointers are to descriptions of the current release of the Java classes. . Language Foundation Classes Package java.lang contains essential Java classes, including numerics, strings, objects, compiler, runtime, security and threads. Unlike other packages, java.lang is automatically imported into every Java program. . Input/Output package java.io Package java.io provides a set of input and output streams to read and write data to files, strings, and other sources. . Utility Class Library Package java.util contains miscellaneous utility classes, including generic data structures, settable bits class, time, date, string manipulation, random number generation, system properties, notification, and enumeration of data structures. . Abstract Window Toolkit Library Package java.awt provides user interface features such as windows, dialog boxes, buttons, checkboxes, lists, menus, scrollbars and text fields. It is said to be `Abstract` because it is device and operating system independent - much to the irritation of some programmers who take their revenge by inventing other meanings for the acronym. .See AWT below and . Applets Package java.applet enables construction of applets. It also provides information about an applet's parent document, about other applets in that document, and enables an applet to play audio. See .See Applet below and . Network Interface Class Library Package java.net network support, including URLs, TCP sockets, UDP sockets, IP addresses and a binary-to-text converter. . Images - Audio and Visual Package java.image is for managing image data, such as the setting the color model, cropping, color filtering, setting pixel values and grabbing snapshots. .Close.Box . Road_works_ahead Two question marks `??` .See 1_below indicate that I haven't found the data yet. If you have found the answer in any offical documentation please send it to dick@csci.csusb.edu where it will be incorporated with an acknowledgement. These are working notes and are being revised daily. Again I am open to corrections and improvements. . Data Types .See http://www/dick/samples/java.semantics.html .Open Object Hierarchy .Open Object .Box For all `C`:Class, `ob`:Object, ob instanceof C::Boolean. Object()::constructor. methods: clone() equals() finalize() getClass() hashCode() notify() notifyAll() toString() wait(long) wait(long,int) wait() . System .Box public final class System extends Object in package java.lang.System This provides a system-independent model of the operating system. It includes the standard input and output streams for example. The standard input streams are used for reading character data. The standard output streams are used for printing. For example: .As_is System.out.println("Hello World!"); The System Class represents a single and predefined `real` object. So it cannot have objects of type System(instances) Nor can it be subclassed. . System Variables err::=`Standard Error Reporting Stream`::PrintStream. .See PrintStream out::=`Standard Output stream`:: PrintStream. .See PrintStream in::=`Standard Input stream`::InputStream. .See InputStream and .See DataInputStream .Open System Methods arraycopy(Object, int, Object, int, int)::=` Copies an array from the source array, beginning at the specified position, to the specified position of the destination array`. exit(int)::= `Exits the virtual machine with an exit code`. .See Array Copy currentTimeMillis()::= `Returns the current time in milliseconds GMT since the epoch (00:00:00 UTC, January 1, 1970)`. See Also .See Date gc()::= `Runs the garbage collector`. getProperties()::= `Gets the System properties`. getProperty(String)::= `Gets the System property indicated by the specified key`. getProperty(String, String)::= `Gets the System property indicated by the specified key and def`. getSecurityManager()::= `Gets the system security interface`. load(String)::= `Loads a dynamic library, given a complete path name`. loadLibrary(String)::= `Loads a dynamic library with the specified library name`. runFinalization()::= `Runs the finalization methods of any objects pending finalization`. setProperties(Properties)::= `Sets the System properties to the specified properties`. setSecurityManager(SecurityManager)::= `Sets the System security`. . Array Copy .Box .As_is public static void arraycopy(Object from_source, int from_source_position, .As_is Object to_destination, int to_destination_position, .As_is int length) Precondition: Both arrays exist and have space for at least `length` objects. Postcondition: First `length` Objects in the second array equal those in first array. Invariant: The first array. .Close.Box .Close System Methods .Close.Box . Color .Box public final class java.awt.Color extends java,lang.Object .See http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Color.html old .See http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Color.html coming colors::={ black, blue, cyan,darkGray, gray, green, lightGray, magenta, orange, pink, red, white, yellow}. Color(float red, float green, float blue)::constructor. Color(int red, int green, int blue)::constructor. Color(int rgb)::constructor. color.getBlue()::int, gets commponent of color. color.getGreen()::int, gets one component of color. color.getRed()::int, gets one component of color. ... .Close.Box . PrintStream .Box public class PrintStream extends Object println(String) .Close.Box . InputStream .Box public class InputStream extends Object (For example the standard input (System.in) .See in ) An abstract class representing an input stream of bytes. All InputStreams are based on this class. InputStream(), available(), close(), mark(int), markSupported(), read(), read(byte[]), read(byte[], int, int), reset(), skip(long) . FilterInputStream .Box . DataInputStream .Box By creating one of these from an unformatted input stream .See InputStream you can attempt to read in simple data types from the resulting stream. DataInputStream(InputStream in)::=`Creates a new DataInputStream`. For S:DataInputStream, S.readLine()::String=`returns a String copy of the line`. For S:DataInputStream, S.readFully(byte[] b)::`reads until blocked into b`. For S:DataInputStream, X:{ Boolean, Byte, Char, Double, Float, Long, Short, UTF, unsignedByte, unsignedShort},S.read`X`()::`X`=`Reads and returns an X`. .Close.Box .Close.Box .Close.Box . Array .Box For each class there is an associated class of arrays. An array has a set of elements of the same class number from 0 to some fixed length. The elements of array `a` are written `a`[0], `a`[1], . . . , `a`[`a`.length-1]. Arrays have a fixed length once created. This is accessable as an field named `length` of each array: length_of_array_a::= `a`.length. Vectors .See http://java.sun.com/j2se/1.4.2/docs/api/java/util/Vector.html (1.4.2), .See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Vector.html are like arrays but can expand when needed. For all `C`:Classes, A:Classes=array_of_C, `i`:identifier, `e`:expression, `a`:array_of_C, `v`:`array_of_C_variable`, `ec`:`C expression`, `C` []::Classes=`class of arrays of objects of class C`::=`A`, `C` [] `i`::declaration=`declare_an_array_of_C`, `C` `i` []::declaration=`declare_an_array_of_C`, `v`=`a`::expression(`A`)=`afterwards v refers to array a`, `v`[`e`]=`ec`::expression(`C`)=`afterwards the e.th element of v has value ec but no other elements of v have been effected`, new `C` [ `e` ]::expression(`A`)=`a new array of e C's`, `a`.length::int=`number of items of class C in array a`, `a`[`e`]::expression(`C`)=`the e.th element of array a`, (`C`[])`ec`::expression(`A`)=`an array with element ec of length 1`?? .See 1_below For all `A`:Classes, `B`:subclasses(`A`), `B`[] in subclasses(`A`[]). For arrays of characters see character strings .See String and StringBuffer For arrays indexed by general objects see hash tables .See HashTable .Close.Box . String and StringBuffer .Box (String): A general class of objects to represent character Strings. Strings are constant, their values cannot be changed after creation. .See http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html .See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html literal::= double_quotes string double_quotes. infix::={"+"}. -- concatenation. -- hence "+=" String()::=`construct new empty string`. String(String), String(char[]), String(char[],int,int), String(byte[], int ,int,int), String(byte[], int), String(StringBuffer)::=`Construct new String copying various data`. charAt(int)::=`character at (_)`. compareTo(String)::int=`lexographic comparison return <0 if <, 0 if equal and >0 if >`. See C.strcmp. concat(String)::=`Place (_) at end of this String`. copyValueOf, endsWith, hashCode(String), intern, equals(String)::boolean=`This string is the same as (_)`. equalsIgnoreCase(String)::boolean, getBytes(int,int,byte[],int)::=`Copy into (3rd)`, getChars(int,int,char[],int)::=`copies chars into (3rd)`. indexOf(...)::int=`position of first matching (_) in this string`. lastIndexOf(...)::int=`position of last matching (_) in this string`. length()::int=`number of chars/bytes in string`. ... substring(int), substring(int,int)::String=`substrings of this string`. toCharArray(), toLowerCase(), toString, toUpperCase, trim()::=`remove leading and trailing whitespace`. valueOf(...)::=`String object cantain representation of (_)`. .Box (StringBuffer): This Class is a growable buffer for characters. It is mainly used to create Strings. But can append any kind of Object which is ?? .See 1_below converted into a sequence of characters before being added to the buffer, `StringBuffer(...)` creates Strings and `StringBuffer append(Object obj)` adds an object to the end of this buffer and returns the StringBuffer itself .See http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html .See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuffer.html append(...)::=`Put (_) after the last character of this string`. capacity()::=`capcity of theis string`. ensureCapacity(int)::=`Make sure room for (_) chars`. charAt(), getChars(), insert(int, X)::=`Inserts an X into the buffer`. length()::int=`number chars in this string buffer`. setCharAt(int, char)::=`change this string's (1st) char to (2nd)`. setLength(int::=`Set length to (_) chars`, toString()::=`converstbuffered data to String`. .Close.Box .Close.Box . Dictionary .Box The Dictionary class is the abstract .See http://www/dic/samples/java.semantics.html#abstract parent of Hashtable, which maps keys to values. Any object can be used as a key and/or value. Any Object has a `hashCode(_)`. Dictionary() elements() get(Object) isEmpty() keys() put(Object, Object) remove(Object) size() .Close.Box . Vector .Box .See http://java.sun.com/j2se/1.4.2/docs/api/java/util/Vector.html .See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Vector.html . Stack Stacks .See http://java.sun.com/j2se/1.4.2/docs/api/java/util/Stack.html .See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Stack.html are Vectors that can accessed at only one end - the "top" - by `push()` and `pop()` operations. .Close.Box . Number .Box Number .See http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Number.html .See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Number.html is an abstract superclass for numeric scalar types, like (Integer):fixed(16.bits, signed), (Long):fixed(32.bits, signed), (Float):floating_point(16.bits,IEEE) and (Double):(32,bits, IEEE): are subclasses of Number .See http://www/dick/samples/java.semantics.html#numeric. Each of these provides a method for extracting the basic data type from the object: (int intValue(Integer), double doubleValue(Double), float floatValue(Float), long longValue(Long)), and a constructor for making the Object from its data ( Integer(int), Long(long),....). .Close.Box . Math .Box (Math Constants): E, PI (Math Functions): abs acos asin atan atan2 ceil cos exp floor log max min pow randon rint round sin sqrt tan Warning: the behavior specified for mathematical functions is implementation dependent. For example they are supposed to throw an exception when the answer is not a number (eg sqrt(-1)). However they have been implemented as calling the standard C library functions and so return Double.NaN(Double's IEEE Not-a-Number value). .Close.Box . Class .Box forName(String) getClassLoader() getInterfaces() getName() getSuperclass() isInterface() newInstance() toString() .Close.Box .Open AWT .Box AWT Component action(Event,Object) addNotify() bounds() checkImage(Image, ImageObserver) checkImage(Image, int, int, ImageObserver) createImage(int, int) deliverEvent(Event) disable() enable() enable(boolean) getBackground() getColorModel() getFont() getFontMetrics(Font) getForeground() getGraphics() getParent() getPeer() getToolkit() gotFocus(Event, Object) handleEvent(Event) hide() imageUpdate(Image, int, int, int, int, int) inside(int, int) invalidate() isEnabled() isShowing() isValid() isVisible() keyDown(Event, int) keyUp(Event, int) layout() list() list(PrintStream) list(PrintStream, int) locate(int, int) location() lostFocus(Event, Object) minimumSize() mouseDown(Event, int, int) mouseDrag(Event, int, int) mouseEnter(Event, int, int) mouseExit(Event, int, int) mouseMove(Event, int, int) mouseUp(Event, int, int) move(int, int) nextFocus() paint(Graphics) paintAll(Graphics) paramString() postEvent(Event) preferredSize() prepareImage(Image, ImageObserver) prepareImage(Image, int, int, ImageObserver) print(Graphics) printAll(Graphics) removeNotify() repaint() repaint(long) repaint(int, int, int, int) repaint(long, int, int, int, int) requestFocus() reshape(int, int, int, int) resize(int, int) resize(Dimension) setBackground(Color) setFont(Font) setForeground(Color) show() show(boolean) size() toString() update(Graphics) validate() .Box AWT Container add(Component) add(Component, int) add(String, Component) addNotify() countComponents() deliverEvent(Event) getComponent(int) getComponents() getLayout() insets() layout() list(PrintStream, int) locate(int, int) minimumSize() paintComponents(Graphics) paramString() preferredSize() printComponents(Graphics) remove(Component) removeAll() removeNotify() setLayout(LayoutManager) validate() .Box AWT Panel Panel() addNotify() .Close AWT . Applet .Box Applet() destroy() getAppletContext() getAppletInfo() getAudioClip(URL) getAudioClip(URL, String) getDocumentBase() getImage(URL) getImage(URL, String) getParameter(String) getParameterInfo() init() isActive() play(URL) play(URL, String) resize(int, int) resize(Dimension) setStub(AppletStub) showStatus(String) start() stop() .Close.Box .Close.Box .Close.Box .Close.Box .Close.Box .Close Object .Close Object Hierarchy .Close The Predefined Classes in Java .Open End Notes (1_below): Indicates something that I think is true but have not been able to check please sen mail to dick@csci.csusb.edu to either confirm or deny the opeinion expressed thereafter. .Close End Notes