© Vaskaran Sarcar 2020
V. SarcarInteractive Object-Oriented Programming in Javahttps://doi.org/10.1007/978-1-4842-5404-2_7

7. Packages

Vaskaran Sarcar1 
(1)
Bangalore, Karnataka, India
 

Let’s consider a simple scenario. Can you use the same name for different classes in a Java file? No. The compiler would raise an issue and would point toward this naming collision. When you define a class, you need to follow unique naming conventions. In real-world programming, class names should be somewhat meaningful, and there is the possibility that different programmers will opt for class names that are not unique. Then the obvious question is: how can you deal with such situations? Packages can rescue us in these instances.

You can bundle your classes or interfaces ...

Get Interactive Object-Oriented Programming in Java: Learn and Test Your Programming Skills now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.