Topic: 一个简单程序(需要 '}',这是为什么?)

  Print this page

1.一个简单程序(需要 '}',这是为什么?) Copy to clipboard
Posted by: wslss007
Posted on: 2005-11-07 22:20

class Person{
String name="";
int age=0;
public Person(String s)
{
String name=s;
}
void setage(int a)
{
  if(a>0&&a<100)
  {
    int age=a;
    }
    }
void show(String name,int age)
{
  System.out.println("name="+name,"age="+age);

  
}
class Chinese extends Person
{
  String shuxiang="";
  String inter="China";
  public Chinese(String s,String pig)
  {
    superMoon;
    String shuxiang=pig;
  }
  void show(){
    super.show();
    System.out.println("shuxiang="+shuxiang,"inter="+inter);
  }
  
}
public class TestPerson
{
public static void main(String args[])
{
  Person per=new Person("shengsi");
  per.setage(24);
  per.show();
  Chinese chin=new Chinese("shengsi","dog");
  chin.setage(24);
  chin.show();
}
}

D:\JCreator Pro\MyProjects\TestPerson.java:48: 需要 '}',这是为什么?


请尽量使用准确的文字描述作为标题
若新帖再無恰当标题,將会被刪除 -- This is the last warning.Evil

void show(String name,int age)
{
System.out.println("name="+name,"age="+age);
} // 需要 '}' here

}

Original subject :
一个简单程序

2.Re:一个简单程序(需要 '}',这是为什么?) [Re: wslss007] Copy to clipboard
Posted by: hualee
Posted on: 2005-11-08 11:30

自己看下{}是不是双数的!!!
用jc把它收起来看明显你少个}在最后


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923