Open Shrikiran11 opened 2 years ago
class Zoo { int animalCount;
Zoo() { } private Zoo(int an) { animalCount = an; }
}
class ZooKeeper { public static void main(String[] args) { Zoo z = new Zoo(92); System.out.println(z.animalCount); } } //compile time error //Zoo(int) has private access in Zoo
class Zoo { int animalCount;
}
class ZooKeeper { public static void main(String[] args) { Zoo z = new Zoo(92); System.out.println(z.animalCount); } } //compile time error //Zoo(int) has private access in Zoo