class Base { public static void f(){} } class Derived extends Base{ private static void f(){} }
the Derived.f () modifier must be public, if it is closed, the compiler says "an attempt to assign weaker access rights was public."I do not understand! Why does the compiler not allow us to do this?
, , . , . , .
, ( private) , ( public), .
private
public
(LSP), - , : , , .
:
public class Base { private static void f() { } } class Derived extends Base { public static void f() { // as well as protected, default, private } }
Source: https://habr.com/ru/post/1654969/More articles:How to access Powerpoint object events (Mac version) using Apple script? - powerpoint-vbaUITextField Chinese character moves down when editing in iOS 10 - ios'init' is not available: use 'withMemoryRebound (to: capacity: _)' - swiftРазница между командами (ICommand) и событием Click - c#UnsafePointer problem in a SQLite project in Swift - pointersSwift 3: zero-term conversion of UnsafePointer to string - stringTransferring an encryption key from Laravel 5.2 to 5.3 - phpFacebook login with Firebase: "auth / timeout" error - javascriptGet the percentage of people for each pair - rWhat is the meaning of '#'? - haskellAll Articles