What is Java Class Library?

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr

Packages Vertex Academy

In this article we will review the following concepts in general terms:

  • Java Class Library
  • packages in Java
  • classes
  • methods

In real life if you would go to the library or bookstore you would definitely see a huge number of books dedicated to different topics: history, mathematics, chemistry, sociology, etc. And you don’t need to discover the continents again – you can just take a book and get an answers to your questions.

And all the books are sorted:

  • on this shelf you will find algebra books
  • on this shelf you will find geometry books
  • on this shelf you will find books dedicated to mathematical analysis
  • etc.

And you know what? In Java there’s a virtual library of tested code, which includes ready-made frameworks for many problems faced by programmers in their daily work. That means that you can take a code from the library and just use it. And it can save a lot of time for a programmer, because you don’t need to write the code from scratch.

The information in this Java virtual library is split into “packages” –  kind of analogue of the bookstore shelves. In each package you can find the tested code on some separate direction.

For example, there are such packages:

  • java.applet
  • java.lang – this is the main package of the Java language
  • java.util
  • java.io
  • java.net
  • etc.

If you are very curious, you can find all the packages on the website of Oracle: https://docs.oracle.com/javase/8/docs/api

Let’s take a look at the schematic illustration of Java libraries.

java-class-library_vertex-academy

As you can see, different packages are shown on the left side of the picture:

  • java.applet
  • java.lang
  • java.util
  • etc.

And what does each package contain? Each package contains classes. We illustrated it through the example of java.lang package. For illustrative purposes we showed one of the classes of the java.lang package – Math class.

We will elaborate on classes in a separate article, when we will talk about object-oriented programming (OOP) in Java. Until then you only need to understand that classes are ready-made frameworks, which can be used for writing your programs.

Each class has its methods (actions), which can be performed by means of class. For example, the Math class has the following methods:

  • sqrt () – derivation of a square root
  • sin () – calculation of a sine of an angle
  • cos () – calculation of a cosine of an angle
  • etc.

That means, that if we need to calculate a square root, we don’t need to write a code that would program the process of square root calculation step by step. And such kind of code will have very many code lines… Instead we just take the Math class from the java.lang package, then we take the sqrt () method which is needed to square root calculation and that’s it – we get a required solution in only one code line.

We hope that now you understand what Java library is, which structure does it have and how effective does it save the precious time of programmers.

Step by step you will get an understanding of different classes and methods in the Java library, and most importantly – how to use them in your code. In the meantime, the mission of our article was to cover this topic in general terms, and our mission is accomplished.

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr

Publiction author

offline 4 hours

Vertex Academy

Comments: 0Publics: 274Registration: 06-03-2016

Leave a Reply

Your email address will not be published.

Subscribe news

Subscribe to our newsletter we will keep you up-to-date!

Самоучители--узнать детальнее--