School of Computer Science Information Technology G 6

  • Slides: 5
Download presentation
School of Computer Science & Information Technology G 6 DICP - Lecture 14 Class

School of Computer Science & Information Technology G 6 DICP - Lecture 14 Class Libraries

Class Libraries Class libraries are pre-defined sets of classes ready for use by developers.

Class Libraries Class libraries are pre-defined sets of classes ready for use by developers. l OO programming is largely about making use of these classes. l The class libraries bundled with the JDK and included in each VM are called the “Core Java Classes” l Class libraries tend to be big - effective use of the documentation is essential. l 2

Packages In Java classes may be grouped into “Packages”, which have hierarchical names. l

Packages In Java classes may be grouped into “Packages”, which have hierarchical names. l The core class libraries are all in packages with the name java. * l For example: l java. lang l java. util l java. io l java. text l java. awt. event l 3 - the main language - useful widgets - i/o (disk access etc) - sophisticated text manipulation - Abstract Windows Toolkit - events for AWT

Using the Core Classes The core class library constitutes the Java API. l Class

Using the Core Classes The core class library constitutes the Java API. l Class libraries tend to be big. l Java core classes (1. 4): l 2, 723 classes in 135 packages l Typically 2 -20 methods per class - very roughly 25, 000 l l An understanding of the documentation is thus essential. http: //java. sun. com/docs/ l http: //java. sun. com/j 2 se/1. 4. 2/docs/api/ l 4

Example Classes l Two important classes from java. lang are: l java. lang. Math

Example Classes l Two important classes from java. lang are: l java. lang. Math Class variables and methods l The variables contain constants ( and e ) l The methods contain mathematical functions (eg Square Root) l Math is not usually instantiated l l java. lang. String Instances of String contain textual data. l Instance methods manipulate that data (eg comparing characters, searching and extracting information). l 5