javaclass-library

how to find java classes?


I am new to programming, I was wondering if there is a way to find the java classes I need for a particular thing other than asking people for them on forums? I have seen the APIs on sun website but there is no good search option to find the class that will work for me.


Solution

  • If you're new to Java (or programming), it's going to be important to learn how to read and understand the documentation in order to become self-reliant -- it's the first step to getting less dependent from other people, and in most cases, will improve your learning and programming speed.

    The following are some tips and suggestions:

    Get to know the Java API Specification.

    At first, the Javadoc format of the API Specification seem a little bit underpowered without any search ability, but I've found that to be that being able to browse the documentation with a browser to be very powerful.

    Since the Javadocs are just HTML files, they can be easily viewed and navigated in a browser, and bookmarking pages are easy as well. Also, the API Specification is available for download, so it not necessary to always go to the web to get information.

    As the documentation is just web pages, using the Find feature of the browser can find information quickly in a page, and if that fails, using Google or your favorite search engine to find documentation is very fast and easy.

    Google (or your favorite search engine) is your friend.

    Need information on the StringBuilder class? Try the following query:

    stringbuilder java 6

    The first result will be the Java API Specification page for the StringBuilder class. The tip is to append the string "java 6" at the end of the query and that seems to bring the API Specification to the top most of the time.

    Get comfortable with the structure of the API Specification.

    The presentation structure of the Javadoc tool is very nice and logical:

    +-----------+-------------------+
    |           |                   |
    |  Packages |                   |
    |           |                   |
    +-----------+      Details      |
    |           |                   |
    |  Classes  |                   |
    |           |                   |
    +-----------+-------------------+
    

    The Javadoc is partitioned into three frames.

    Generally, looking for a class starts from selecting a package from the top-left hand frame, then looking for the class in the bottom-left frame, and finally browsing through the details on the right hand frame. The idea is:

    Package -> Class -> Details
    

    The details in the right hand frame for the classes and packages are also very structured. For classes, the structure are as follows:

    When I'm looking for information on a method, I will scroll down to the Method Summary, find the method I want, and click on that method name which will jump to the Method Details.

    Also, everything about the class is documented in one page -- it may seem like it is too much information for one page, but it does make it easy to get all the information you need about the class from one location. In other documentation formats, it may be necessary to flip between multiple pages to get information about several methods in the same class. With the Javadoc format, it's all in one page.

    Learn the Java Platform API

    The next step is to learn the important packages of the Java Platform API. This will aid in quickly finding classes from the huge collection of classes in the platform API.

    Don't worry, take it slow -- you don't need to learn everything at once!

    Some packages of interest are:

    Knowing where classes are and starting to get a feel of where to look in the vast amount of documentation will make it easier to find information. It will probably take a while to get used to it, but once you get a hang of it, it should be much easier, and you'll be able to find the information on your own.

    Good luck!