package pkg1[.pkg2[.pkg3…]];
package net.java.util; public class Something{ ... }
package animals; interface Animal { public void eat(); public void travel(); }
package animals; /* 文件名 : MammalInt.java */ public class MammalInt implements Animal{ public void eat(){ System.out.println("Mammal eats"); } public void travel(){ System.out.println("Mammal travels"); } public int noOfLegs(){ return 0; } public static void main(String args[]){ MammalInt m = new MammalInt(); m.eat(); m.travel(); } }
import package1[.package2…].(classname|*);
package payroll; public class Boss { public void payEmployee(Employee e) { e.mailCheck(); } }
package vehicle; public class Car { // 类实现 }
package com.runoob.test; public class Runoob { } class Google { }