⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 animal.java

📁 this is a java application
💻 JAVA
字号:
interface Animal
{
	void eat();
	void sleep();
}

class Zoo
{
	private class Tiger implements Animal
	{
		public void eat()
		{
			System.out.println("tiger eat");
		}
		public void sleep()
		{
			System.out.println("tiger sleep");
		}
	}
	Animal getAnimal()
	{
		return new Tiger();
	}
	/*Animal getAnimal()
	{
		return new Animal()
		{
			public void eat()
			{
				System.out.println("animal eat");
			}
			public void sleep()
			{
				System.out.println("animal sleep");
			}
		};
	}*/
}

class Test
{
	public static void main(String[] args)
	{
		Zoo z=new Zoo();
		Animal an=z.getAnimal();
		an.eat();
		an.sleep();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -