private方法在子类(不同的包)中可以访问吗?

Test4:
package com.winsunlight;
public class Test4{
protected void weather(){
System.out.println("today is rainy!");
}
}
Test3:
package cn.mybole;
import com.winsunlight.Test4;
class Test3{
public static void main(String args[]){
Test4 t4=new Test4();
t4.weather();
}
}

系统提示不能在com.winsunlight.Test4中访问 t4.weather()
不好意思写错了 我说的是protected 方法 结果写成了private

不可以 public或者protected

送你张图

温馨提示:内容为网友见解,仅供参考
第1个回答  2010-10-22
用 protect
相似回答