Download presentation
Presentation is loading. Please wait.
Published byPercival Collins Modified over 9 years ago
1
School of Computer Science & Information Technology G6DICP - Lecture 14 Class Libraries
2
2 Class libraries are pre-defined sets of classes ready for use by developers. Class libraries are pre-defined sets of classes ready for use by developers. OO programming is largely about making use of these classes. OO programming is largely about making use of these classes. The class libraries bundled with the JDK and included in each VM are called the “Core Java Classes” The class libraries bundled with the JDK and included in each VM are called the “Core Java Classes” Class libraries tend to be big - effective use of the documentation is essential. Class libraries tend to be big - effective use of the documentation is essential.
3
3 Packages In Java classes may be grouped into “Packages”, which have hierarchical names. In Java classes may be grouped into “Packages”, which have hierarchical names. The core class libraries are all in packages with the name java.* The core class libraries are all in packages with the name java.* For example: For example: java.lang- the main language java.lang- the main language java.util- useful widgets java.util- useful widgets java.io- i/o (disk access etc) java.io- i/o (disk access etc) java.text- sophisticated text manipulation java.text- sophisticated text manipulation java.awt- Abstract Windows Toolkit java.awt- Abstract Windows Toolkit java.awt.event- events for AWT java.awt.event- events for AWT
4
4 Using the Core Classes The core class library constitutes the Java API. The core class library constitutes the Java API. Class libraries tend to be big. Class libraries tend to be big. Java core classes (1.4): Java core classes (1.4): 2,723 classes in 135 packages 2,723 classes in 135 packages Typically 2-20 methods per class - very roughly 25,000 Typically 2-20 methods per class - very roughly 25,000 An understanding of the documentation is thus essential. An understanding of the documentation is thus essential. http://java.sun.com/docs/ http://java.sun.com/docs/ http://java.sun.com/j2se/1.4.2/docs/api/ http://java.sun.com/j2se/1.4.2/docs/api/
5
5 Example Classes Two important classes from java.lang are: Two important classes from java.lang are: java.lang.Math java.lang.Math Class variables and methods Class variables and methods The variables contain constants ( and e ) The variables contain constants ( and e ) The methods contain mathematical functions (eg Square Root) The methods contain mathematical functions (eg Square Root) Math is not usually instantiated Math is not usually instantiated java.lang.String java.lang.String Instances of String contain textual data. Instances of String contain textual data. Instance methods manipulate that data (eg comparing characters, searching and extracting information). Instance methods manipulate that data (eg comparing characters, searching and extracting information).
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.