Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
外部からインスタンス化される別のパッケージで (継承しないクラスから) 使用されるクラスを保護するにはどうすればよいですか? これはJavaでも可能ですか?
コンストラクターを保護する
public class ProtectClass { protected ProtectClass() { // TODO Auto-generated constructor stub } }
まあ、抽象クラスをインスタンス化することはできませんが、それはあなたが探しているものではないかもしれません...これが可能だとは聞いたことがありません。