For Video Tutorial : Move on Youtube Channel
Note : Select the playlist as per your need & move with number sequence
Package in java with example
Video for this tutorials : CLICK HERE
When we talk about the package means that we are talking about certain similar things.
Same is in java package, So java package is a collection of similer files, classes, methods etc.
In java , there s two type of package :
1) Built-in package such as java, lang, awt, javax , swing, net, io, etc.
2) User defined package.
Advantage of Java package1. It removes the naming collision.
2. It provides access protection.
3. Effective way to maintain classes and interface.
Note : It is good practice to give package name in small letter. Example : In below example we have created a package & inside it there is a class then we have created another class in another package and then we imported the package and accessed the class.
package csc_pack; public class Chandan1
public void sum(int a, int b)
System.out.println("Your sum is :" +(a+b));
Now import this package in another class :
public class Mainclas
public static void main(String args)
Chandan1 obj = new Chandan1();
Your sum is :7