CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ

Java

Java Programming
Classes, objects, and methods

  • Only a small number of operations are defined in Java. Many of the methods and identifiers needed to run a Java program are provided as a collection of libraries.
  • A package is a collection of related classes and that every package has a name.
  • The term class is broadly used. It is used to create Java programs (either application or applet), it is used to group a set of related operations, and it is used to allow users to create their own data types.
  • Each of these operations is implemented using the Java mechanism of methods.
  • A method is a set of instructions designed to accomplish a specific task.
  • To make use of the existing classes, methods, and identifiers, you must specify the packages that contain the appropriate information using the reserved word import.

Common Java packages

Package name Description
java.lang Provides classes fundamental to Java, including classes that work with primitive data types, strings, and math functions.
java.text Provides classes to handle text, dates, and numbers.
java.util Provides various utility classes including those for working with collections.
java.io Provides classes to read data from files and to write data to files.
java.sql Provides classes to read data from databases and to write data to databases.
java.applet An older package that provides classes to create an applet.
java.awt An older package called the Abstract Window Toolkit (AWT) that provides classes to create graphical user interfaces.
java.awt.event A package that provides classes necessary to handle events.
javax.swing A newer package called Swing that provides classes to create graphical user interfaces and applets.

Previous | Classes, objects, and methods | Import Java classes | Create objects | Call methods | Use API documentation to research Java classes | Next