本帖最后由 那些人之一 于 2013-12-6 09:54 编辑
- <IMG border=0 alt="" src="http://bbs.itheima.com/forum.php?mod=image&aid=31526&size=300x300&key=4dd276914339d03d&nocache=yes&type=fixnone" aid="attachimg_31526">package pack;
- //import mydemo.*; //导入mydemo包中的所有类
- class Packagedemo
- {
- public static void main(String[] args)
- {
- mydemo.DemoA d=new mydemo.DemoA();
- d.show();
- packo.Demo b= new packo.Demo();
- b.method();
- System.out.println("Hello Package!");
- }
- }
- <DIV class=blockcode>
- <BLOCKQUOTE>package mydemo;
- public class DemoA extends packo.Demo
- {
- public void show()
- {
- method();
- System.out.println("DemoA show run");
- }
- }
- <DIV class=blockcode>
- <BLOCKQUOTE>package packo;
- public class Demo
- {
- public /*protected 保护*/ void method()
- {
- System.out.println("Demo method run");
- }
- }
复制代码
|
|