I'm a pretty new Java student and I was just confused on a few basic concepts. What exactly is the difference between public and private classes and in which case would you use each one? also, what is a constructor, mutator, or accessor?
a private class? maybe for inner classes, but I definitely wouldn't recommend it otherwise :)
The all-important JLS section 8.1.1 says
The access modifiers protected and private (§6.6) pertain only to member classes within a directly enclosing class or enum declaration (§8.5).
For example you may have a class that represents a collection of Things that you will want to sort in various different orders. You create private member classes for the different Comparators that you use in your sorting.
public amd private are the access modifire.This modifires are allowed on variables,methods and classes.
If we want to access a class anywhere then make this class as public using public keyword.
In the case PACKAGE,public class can be access within the same package or in the other package
But private class can't be access in the same package or in the other package.
Simply we say that public are write once and access anywhere but private can't.
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...