【菜鸟求助】java接口问题
Java code:
package MainCon;
public interface Animal {
void voice();
}
class Dog implements Animal {
public void voice() {
System.out.println("W W!");
}
}
class cat implements Animal{
public void voice(){
System.out.println("M M!");
}
}
class pig implements Animal{
public void voice(){
System.out.println("GU LI");
}
}
class Store {
public static Animal get(String choice){
if(choice.equalsIgnoreCase("dog")){
return new Dog();
}else if(choice.equalsIgnoreCase("pig")){
return new Dog();
}else{
return new cat();
}
}
}
public class AnimalTest{
public static void main(String[]args){
Animal a1 = Store.get("dog");
a1.voice();
Animal a2 = Store.get("pig");
a2.voice();
}
}
AnimalTest类报错、
The public type AnimalTest must be defined in its own file
-----------------------------
我是个新学的菜鸟,撒都不懂,希望高手指点下。万分感谢!
public interface Ani
相关问答:
用RandomAccessFile写入TXT文件查看时是乱码,请问有什么方法可以写成可读的文件,不是用其他的文件操作,就是只用RandomAccessFile的方法是否可以实现?
Java code:
import java.io.*;
public class RandomAcce ......
Java code:
public static void main(String[] args)throws Exception {
String json="{\"installer_id\":\"00000003\",\"installer_name\":\"王五\& ......
当知道一个日期,如何把这个日期所在旬的前后两个日期取出
比如输入20090905,就输入20090901 20090910
输出20090901 20090910
取得天数后作一下判断再把这个方法用下void set(int field, int value)
......
public class Student{
//字段的定义
private String _number; //学号
private String _name; //姓名
private   ......
在安装Java编译器的Eclipse的时候,对环境变量进行了配置,在安装MySQl的时候也要对环境变量进行配置;那么后面的配置会影响前面的Eclipse的配置吗?
请大家多指教~!谢谢!
不会把,我这都装了的 我系统里 还装了 ......