The Java application programming interface (API) consists of classes created by Sun Microsystems and stored in library files called packages .
We use classes from java.lang, java.awt, java.applet.
For the other classes see table on next slide.
Partial List of Core Java API Packages Core functions of the language, automatically included java.lang Handle input and output of data java.io Create software components java.beans Graphical components using abstract windows toolkit java.awt Create applets java.applet Purpose Package
Partial List of Core Java API Packages Continued Purpose Package Provide utilities such as dates java.util Manipulate text including searches java.text GUI using Java Foundation Classes java.swing Query databases java.sql Manage certificates, signatures, and other security java.security Remote objects java.rmi Networking java.net Handle math functions, very large integers and decimal values java.math
A class is a template or blueprint for an object, but is not the object itself.
Let us take an example of a dog:
We can describe the characteristics of a certain breed of dog, such as typical coloring and general size and whether the breed barks, bites, or runs fast and descriptions are the properties and methods of the class.
But an actual dog (an instance of the dog class) will have a set of characteristics, such as a name and a size.
This means you instantiate object of the dog class to create an instance of the dog.
must contain only letters, numbers, and underscores.
must begin with a letter or underscore.
cannot have any embedded spaces.
is case sensitive.
Cannot be one of Java's reserved words, such as boolean , public , or import . (Note that all of the Java reserved words are lowercase. If you use uppercase as part of your names, you will never have a naming conflict.
Make all names meaningful. Do not use names such as a, b, c, or x. Always create names that a person reading your code can tell the purpose of. And do not abbreviate unless using a standard abbreviation that has a clearly understood meaning.
Begin the name with a lowercase prefix that indicates the type of component.
The execution of an applet in a browser follows a specific cycle.
Each applet always executes four methods: init, start, stop , and destroy.
The only method you are writing currently is the init method.
The Methods in the Life Cycle of an Applet Executes prior to shut down of the browser destroy Executes when the browser leaves a Web page containing the applet stop Follows the init and reexecutes each time that the page displays start Executes the first time an applet is loaded init Purpose Method