X hits on this document

118 views

0 shares

0 downloads

0 comments

34 / 46

© S. Uchitel, 2004

34

Import

How to access classes in a package?

Fully qualify class name e.g., java.util.Date, or

Import  the class and use short name e.g. Date

Example:

import java.util.Random;

. . .

Random r = new Random();

java.util.Date d = new java.util.Date();

. . .

Exception: there is no need to fully qualify

nor import classes in java.lang such as String.

String greeting = new String(“Hello world”);

// equivalent to greeting = “Hello world”;

Document info
Document views118
Page views118
Page last viewedFri Dec 09 08:44:11 UTC 2016
Pages46
Paragraphs816
Words2901

Comments