本帖最后由 小小菜鸟 于 2014-1-7 06:55 编辑
- class Person{
- private String name;
- private int age;
- Person(int age){
- this.age = age;
- }
- Person(int age,String name){
- this.age = age;
- this.name = name;
- }
- public void speak(){
- System.out.println("cry....");
- }
- public boolean compare(Person p){
- return(this.age==p.age);
- }
- }
- public class PersonDemo2{
- public static void main(String[] args) {
- Person p1 = new Person(20);
- Person p2 = new Person(25);
- boolean b = p1.compare(p2);
- System.out.println(b);
-
-
- }
- }
复制代码
在eclipse中显示的是第一行有错。。。但我感觉没错呀。。不能运行。怎么回事?? |