13. Using the Java API

Sunday, August 23, 2009 Posted by Sudarsan
The Java class library contains thousands of predefined classes and interfaces that programmer can use to write their own applications. These classes are grouped into packages based on their functionality.

For example, the classes and interfaces used for file processing are grouped into the java.io package, and the classes and interfaces for networking applications are grouped into the java.net package.

The Java API documentation lists the public and protected members of each class and the public members of each interface in the Java class library. The documentation overviews all the classes and interfaces, summarizes their members (the fields, constructors and methods of a class and the fields and methods of interfaces) and provides detailed description of each member.

Most Java programmers rely on this documentation when writing programs.

Normally, programmers would search the API to find the following:

1. The package that contains a particular class or interface.

2. Relationships between a particular class or interface and other classes and interfaces.

3. Constructors to determine how an object of the class can be initialized.

4. The methods of a class to determine whether they are static, or non-static, the number and type of the arguments we need to pass, the return types and any exceptions that might be thrown from the method.

The Java API can be downloaded to your local hard disk or viewed online. To download the Java API, go to DOWNLOAD.

Here are some screenshots which will guide you, how to use Java API.

1. After downloading Java API open index.html page in doc folder.
Then you will see the fallowing page.


2.Clik on API, Language, & VM link in the page, then you will see all the packages listed in alphabetical order in upper left frame, lower-left frames lists all classes and interfaces, interfaces are displayed in italics.


3. For instance click on java.util package in Upper-left frame. Then you will see the fallowing page.


4. From the lower-left frame click Scanner class link, then you can see all the fields and methods in Scanner class like below.


5.For instance click the nextInt() method to view the method’s details.

 

6.Field summary for a class will be provided at the top of the Right frame, here you can see field type and field details also.


In the next post, we are going to preset How Java API is associated with Arrays.Keep an ey on the Next Post.
Labels:

Post a Comment