Public Class In Java
We make a class public when we have to make our class attributes, data members, and member methods accessible from another package as well.
Now we will see Example -
Example 1 - In this example, we will use data from the second package in the first package.
Using this package data into our primary package
Output -