p***p 发帖数: 559 | 1 涵义当然明白,只有本package才能使用,请问在
编程上代表一种什么意图,实现什么想法时候用
public当然好理解,private也是,只有通过get
set才能使用,作者可以控制。 | w*r 发帖数: 2421 | 2 let's say you have a abstract class and it will be inherited by
some other classes in the same package, here is a abstract function that
all extended class should have to make it work .As you can read from the
following example, all vehicles should have mechanism to speedup and slow
down , however, speedup and slowdown are two "internal" mechanisms, which
each type of vehicle may carry differnet public function to trigger speedup
or slowdown, such as applyMoreGas() for car, peddleFaster() for bi
【在 p***p 的大作中提到】 : 涵义当然明白,只有本package才能使用,请问在 : 编程上代表一种什么意图,实现什么想法时候用 : public当然好理解,private也是,只有通过get : set才能使用,作者可以控制。
| b********l 发帖数: 27 | 3 这个看看design pattern 会有比较直观的应用理解。
【在 p***p 的大作中提到】 : 涵义当然明白,只有本package才能使用,请问在 : 编程上代表一种什么意图,实现什么想法时候用 : public当然好理解,private也是,只有通过get : set才能使用,作者可以控制。
| g*****g 发帖数: 34805 | 4 No, protected is mainly for visiblity in subclasses, although it's also
visible in the same package.
For visibility in the same package only, use default or no descriptor.
If you are developing an API package, there is a huge difference between
default and protected restriction. Default or private is internal to the
package and thus can be easily changed later on. protected and public are
exposed signature and "committed" to outside world. They need careful design
and any later change may be co
【在 p***p 的大作中提到】 : 涵义当然明白,只有本package才能使用,请问在 : 编程上代表一种什么意图,实现什么想法时候用 : public当然好理解,private也是,只有通过get : set才能使用,作者可以控制。
|
|