# Difference Between Packages and Interfaces in Java

JavaServer Side ProgrammingProgramming

In this post, we will understand the difference between packages and interfaces in Java.

## Packages

• It is a group of classes and/or interfaces that are together.

• It can be created using the "Package" keyword.

• It can be imported.

• It can be done using the "import" keyword.

## Example

package package_name;
public class class_name {
.
(body of class)
.
}

## Interfaces

• It is a group of abstract methods and constants.

• It can be created using the "Interface" keyword.

• It can be extended by another interface.

• It can also be implemented by a class.

• It can be implemented using the ‘implement’ keyword.

## Example

interface interface_name {
variable declaration;
method declaration;
}
Published on 24-Mar-2021 13:05:30