class Cat{
String name;
int age;
String color;
public void set(String name,int age,String color){
this.name=name;
this.age=age;
this.color=color;
}
public String toString(){
return "姓名:"+name+"\t年龄:"+age+"\t颜色:"+color;
}
public Cat abc(){
return this;
}
}
public class A6_11{
public static void main(String[] args){
Cat one=new Cat();
Cat two=new Cat();
one.set("小明",12,"黑色");
two.set("小红",14,"紫色");
Cat three=new Cat();
three=two.abc();
System.out.println(one);
System.out.println(two);
System.out.println(three);
}
}
这里总是提示Cat类 The type Cat is already defined
我用记事本编的一样的程序在CMD下就可以运行。这是为啥呢
class Cat{
String name;
int age;
String color;
public void set(String name,int age,String color){
this.name=name;
this.age=age;
this.color=color;
}
public String toString(){
return "姓名:"+name+"\t年龄:"+age+"\t颜色:"+color;
}
public Cat abc(){
return this;
}
}
public class A6_11{
public static void main(String[] args){
Cat one=new Cat();
Cat two=new Cat();
one.set("小明",12,"黑色");
two.set("小红",14,"紫色");
Cat three=new Cat();
three=two.abc();
System.out.println(one);
System.out.println(two);
System.out.println(three);
}
}
这里总是提示Cat类 The type Cat is already defined
我用记事本编的一样的程序在CMD下就可以运行。这是为啥呢
本博客详细解释了在使用MyEclipse10进行Java编程时,遇到的关于类名重复定义的错误,并提供了解决方案。通过分析代码实例,本文探讨了可能导致此类错误的原因,以及如何正确地管理和定义类以避免此类问题。此外,还对比了使用记事本编写的代码与在Eclipse环境下运行的差异,帮助开发者理解不同IDE之间的兼容性和注意事项。


被折叠的 条评论
为什么被折叠?



