请教高手,下面的程序错在那里??(关于toString方法的)
java吧
全部回复
仅看楼主
level 1
public class gugu{ static int a=10; static int b=18; static int c=23; public String toString(){ return "sum="+(a+b+c); } gugu d=new gugu(); String h=d.toString(); System.out.println(h); } 最后一排报错,信息如下:(1)Syntax error on token "h", VariableDeclaratorIexpected after this token(2)Syntax error on token(s), misplaced construct(s)请各位赐教!不胜感谢!
2006年06月03日 06点06分 1
level 1
public class gugu{ static int a=10; static int b=18; static int c=23; public String toString(){ return "sum="+(a+b+c); } public static void main(String[] argv){gugu d=new gugu(); String h=d.toString(); System.out.println(h); }}
2006年06月03日 06点06分 2
level 1
帮你问问http://bbs.easwos.com的达人
2006年06月03日 07点06分 3
level 1
十分感谢!
2006年06月03日 09点06分 4
level 1
你的问题在于:不能把非声明的操作方法放在class里面,而是要放在方法里面。shiyiwan的更改是正确的,把操作的语句放在Main函数里面。
2008年04月02日 03点04分 5
level 0
import com.ibm.mq.*; 你把需要的jar文件都放project里面了么?
2008年04月28日 07点04分 7
level 1
看不懂代码为什么还要抄别人的?别人的包:import com.ibm.mq.*你有吗?用豆浆机喝豆浆不给黄豆,豆浆能香吗?
2008年04月28日 13点04分 8
level 1
缺少包
2008年04月29日 02点04分 9
1