Presentation is loading. Please wait.

Presentation is loading. Please wait.

Building a program (Java libraries) - an example

Similar presentations


Presentation on theme: "Building a program (Java libraries) - an example"— Presentation transcript:

1 Building a program (Java libraries) - an example
12 Building a program (Java libraries) - an example

2 Previously Data Structures Arrays Java Arrays Java Especial for loop
User Defined Data Types

3 Overview Class Libraries Packages Using Core Java Classes Process
Packages Views Javadoc Output – HTML View

4 Class Libraries Pre-defined set of classes ready for use by developers
Object Oriented is in great part about using these – using already existing classes (libraries) They are the “Core Java Classes” They are part of the VM and JDK Class libraries tend to be big Use of the documentation is essential

5 Packages Java classes maybe grouped into “Packages”
Packages have hierarchical names The core class libraries are all in package with the name java

6 import java.util.Scanner;
Packages Some of the core Java library components java.lang the main part of the language java.util useful classes (e.g. Scanner) java.io input and output device access (e.g. disk) java.text text manipulation You have been using already a package in the Celsius to Fahrenheit exercise import java.util.Scanner; System is a class from java.lang also all the wrapper classes are from java.lang

7 Packages To use a class from a package you need to
Include it into your class file At the top of the file (after the line that starts with package if one exists) import java.util.Scanner; public class CelsiusToFahrenheit { ... } // end class CelsiusToFahrenheit To use classes from package java.lang it is not required to include it into your class file

8 Packages Use * to include all the classes in the package
import java.util.*; public class CelsiusToFahrenheit { ... } // end class CelsiusToFahrenheit If you are suing more than three classes from that package then use the * format

9 Using Core Java Classes
The core class library constitutes the Java API Reach in functionality, i.e. Classes and methods Documentation

10 Using Core Java Classes
Lets look at the Java API documentation

11 Process Create project Create classes and interfaces
Provide an entry point Application public static void main(String[] astrArgs) Introduce statements Document your code Comments for documentation Comments to explain internal workings Do break down the specifications to make the process of coding easier

12 Process Project files .java are the development files
For human use Contains code and comments .class are the compiled files part of the executable For machine use – VM Contains code that VM understand – not for human viewing

13 Process HiThere.java (531bytes) HiThere.class (567bytes)

14 Packages Views The application

15 Packages Views Windows Explorer Eclipse

16 Javadoc Output – HTML View


Download ppt "Building a program (Java libraries) - an example"

Similar presentations


Ads by Google