访问权限,控制对象的生成
package thinking; public class Soup { private Soup(){}; public static Soup makeSoup(){ System.out.println("soup"); return new Soup(); } private static Soup soup = new Soup(); public static Soup access(){ return soup; } }
protected:
可由从这个类继承的任何东西或者同一个包的其他任何东西访问;