Skip to main content

Java Packages

Check full java topics on this main page

Package

In simple terms, the package is just like a normal folder in your gadget. In your gadget, you will be having a separate folder for games, music, movies, etc.., As like that package in java contains a group of classes, interfaces, methods, and sub-packages. 
Its requirement is simple and useful - To organize classes and make it easier to find the required data

In Java, there are two types of packages,
  1. User-defined Packages
  2. In-Built packages
Let us see how to create user-defined packages. To create a package in eclipse follow the below steps
  • Create a Java project in eclipse
                    
  • Right click on the folder New -> Package
        
  • While creating a package if you are facing any issue with the source path, Right-click on folder Build Path -> Use as Source Folder
         
  • Under a package, We can create classes or interface or sub-packages or folders

                       


What are In-Build packages in Java?

Java provides a wide range of build-in packages like java.lang, java.util,  java.io, etc.., which has classes and methods in it. 
If we need any classes or methods from those packages we can import that package to our program.
To import build in packages need to put the keyword import below the user-defined package and put the inbuilt package name after import

                import java.util.ArrayList;

              


We will be using packages in our upcoming topics. 
If you are unclear about this don't worry while working on classes and methods you will understand that

Feel free to post your queries to us!!!

Comments