| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 414 人关注过本帖
标题:[求助]看下这2段程序有错没有
取消只看楼主 加入收藏
小斑点
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-6-18
收藏
 问题点数:0 回复次数:2 
[求助]看下这2段程序有错没有
/* This program contains an error.
A subclass must come before its superclass in
a series of catch statements. If not,
unreachable code will be created and a
compile-time error will result.
*/
class SuperSubCatch {
public static void main(String args[]) {
try {
int a = 0;
int b = 42 / a;
} catch(Exception e) {
System.out.println("Generic Exception catch.");
}
/* This catch is never reached because
ArithmeticException is a subclass of Exception. */
catch(ArithmeticException e) { // ERROR - unreachable
System.out.println("This is never reached.");
}
}
}



class TempClass
{
public int X(int [] a) throws TempException
{
if (a.length<>23)
throw new TempException("the number of the array is "+a.length);
or
if (y<=0)
throw new TempException("Divisor is "+y);
int Y;
Y=a.length;
System.out.println("the number of the array is "+a.length);
return Y;
}
}


class TempException extends Exception
{
public TempException(String msg)
{
super(msg);
}
}

class Test
{
public static void main(String [] args)
{

int a = args.length;
System.out.println("a = " + a);
int b = 23 / a;
int c[] = { 1 };
c[23] = 99;
}

catch(TempException e)
{
System.out.println(e.getMessage());
System.out.println("异常");
e.printStackTrace();
}

}
}




帮我看下哪里有错好么
谢谢了~

2006-06-22 18:33
小斑点
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-6-18
收藏
得分:0 
我也。。。
不知道错在哪里啊。。。
"or"?
能说详细点么

2006-06-22 19:09
小斑点
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-6-18
收藏
得分:0 
谢谢几位的帮忙~

2006-06-22 21:09
快速回复:[求助]看下这2段程序有错没有
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.104615 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved