Section A.10. Packages


[Page 549 (continued)]

A.10. Packages

The Java classes are grouped into packages. You can use any of classes in the package java.lang. If you wish to use classes in packages other than java.lang, you can use an import statement. Import statements go before the class declaration in a file. You can import all the classes in a package using:

import name.*;


or you can import just a named class using:

import name.ClassName;


To import all classes in the java.awt package use:

import java.awt.*;



[Page 550]

To import just the class java.awt.Color use:

import java.awt.Color;


If you don't import the package or the class, you can use the full name, which is the package name followed by '.' and then the class name (java.awt.Color).

Here is a table of some of the packages in Java and the interfaces and classes we have used from each of these packages. The interfaces are shown in italics.

java.lang

Basic classes in the language

Comparable, Object, String, Math

java.io

Classes for input and output

BufferedReader, BufferedWriter, FileReader, FileWriter, Reader, Writer, File

java.awt

Classes for drawing

Paint, Color, Font, Image, Graphics, Graphics2D

java.net

Classes for use with networks

URL

java.sql

Classes for use with databases

Connection, Statement, ResultSet, DriverManager

java.util

Utility and collection classes

Iterator, List, Map, ArrayList, HashMap, TreeMap




Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
ISBN: N/A
EAN: N/A
Year: 2007
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net