對于繼承,static :hide;non static :override.
  
關(guān)鍵字:包訪問權(quán)
當屬性或方法前不聲明訪問權(quán)是默認為包訪問權(quán).
具有包訪問權(quán)的方法或者屬性只能被同一個包內(nèi)的其他類訪問.
處于相同目錄的類之間具有默認的包訪問權(quán)限.即可以訪問其他文件的包訪問權(quán)限方法.
//處于不同包類不能訪問具有包訪問權(quán)限的方法或?qū)傩?
package animal;
public class animal
{
 void bite()
 {
 System.out.println("bite");
 }
}
package test;
import animal.*;
public class test
{
   public static void main(String args[])
   {

       animal animal=new animal();
       animal.bite();//因為bite()只具有包訪問權(quán)
}
}
// 處于相同目錄的類之間具有默認的包訪問權(quán)限.即可以訪問其他文件的包訪問權(quán)限方法.
public class test
{
   public static void main(String args[])
   {
   animal animal=new animal();
   animal.bite();
  }
}
public class test
{
   public static void main(String args[])
   {
   animal animal=new animal();
   animal.bite();
  }
}

package test;
import animal.*;
public class dog extends animal    繼承但是不屬于同一個包
{
   public static void main(String args[])
   {
      dog dog=new dog();
      dog.bite();//bite只是具有包訪問權(quán)

   }
}
PROTECTED 關(guān)鍵字:繼承訪問權(quán)限! 
導(dǎo)出類可以使用在基類定義為PROTECTED的方法,對于同一個包的非繼承關(guān)系類具有包訪問權(quán)!
在同一個包中,可以通過在子類中超類的實例來訪問超類的protected變量,而不在同一個包中,就不能這樣做
protected 指定該變量可以被同一個包中的類或其子類訪問,但是不能通過超類的實例來實現(xiàn),在子類中可以覆蓋此變量
public class animal
{
 protected void bite()
 {
System.out.println("bite");
 }
}
public class test
{
   public static void main(String args[])
   {
   animal animal=new animal();
   animal.bite();
  }
}
導(dǎo)出類可以使用基類的PROTECTED方法
package animal;
public class animal
{
 protected void bite()
 {
 System.out.println("bite");
 }
}

package test;
import animal.*;
public class dog extends animal
{
   public static void main(String args[])
   {
      dog dog=new dog();
      dog.bite();//bite只是具有包訪問權(quán)
}
}
Private關(guān)鍵字
具有Private關(guān)鍵字的方法只能被定義該方法的內(nèi)部
public class animal
{
  private String s="fasf";
  private void test()
  {}
 protected void bite()
 { System.out.println("bite");}
}
public class test
{
   public static void main(String args[])
   {
   animal animal=new animal();
   //animal.s="fafaf";  can not access private
  // animal.test();    can not access private 
   animal.bite();
  }
}
//私有構(gòu)造函數(shù)
class privatetest
{
    private privatetest()
    {}
    public static privatetest make()
    {
    return new privatetest();
    }
    public void f()
    {
  System.out.println("success");
 }
}
public class test
{
   public static void main(String srgs[])
   {
       privatetest pt=privatetest.make();
       pt.f();
 }
}
類的訪問權(quán)限  類的訪問權(quán)限只能是缺省或者是"public"
//包訪問權(quán)限:
package animal;
 class animal
{
 protected void bite()
 { System.out.println("bite");}
}
package test;
import animal.*;
public class test
{
   public static void main(String args[])
   {  animal animal=new animal();  // can  not access from outside package;
       animal.bite();//因為bite()只具有包訪問權(quán)
     }
}