Java Packages & API-10 example

  • Built-in Packages (packages from the Java API)
  • User-defined Packages (create your own packages)

Syntax

import package.name.Class; // Import a single class

import package.name.*; // Import the whole package

We will see example so it will clear.

User-defined Packages

To create your own package, you need to understand that Java uses a file system directory to store them. Just like folders on your computer:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store