Java 新手,protected問題.

提示: 作者被禁止或刪除 內容自動屏蔽

Instance variables or methods can be accessed by the class itself and its subclasses.

Your example doesn't show any inheritance. You just create a Target object, which of coz have the right to access the String2() method.

TOP