0% found this document useful (0 votes)
2 views

Java Classes - Lecure#9

The document explains the concept of packages in Java, describing them as groups of classes, interfaces, and other packages. It outlines the types of packages, including built-in and user-defined packages, and highlights the advantages of using packages such as reusability, better organization, and avoidance of name conflicts. Overall, packages enhance the efficiency and structure of Java projects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Java Classes - Lecure#9

The document explains the concept of packages in Java, describing them as groups of classes, interfaces, and other packages. It outlines the types of packages, including built-in and user-defined packages, and highlights the advantages of using packages such as reusability, better organization, and avoidance of name conflicts. Overall, packages enhance the efficiency and structure of Java projects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Object-Oriented Programming

(OOP)
Classes
Packages in java
►A package as the name suggests is a
pack(group) of classes, interfaces and other
packages
► types of packages
▪ built-in packages
►Import java.util.Scanner
►→ java is a top level package
→ util is a sub package
→ and Scanner is a class which is present in the
sub package util.
▪ user defined package
Advantages of using a package in Java
► Reusability: While developing a project in java, we often feel
that there are few things that we are writing again and again
in our code. Using packages, you can create such things in
form of classes inside a package and whenever you need to
perform that same task, just import that package and use the
class.
► Better Organization: Again, in large java projects where we
have several hundreds of classes, it is always required to group
the similar types of classes in a meaningful package name so
that you can organize your project better and when you need
something you can quickly locate it and use it, which improves
the efficiency.
► Name Conflicts: We can define two classes with the same
name in different packages so to avoid name collision, we can
use packages

You might also like