两个程序,分别为ServerTimout.java,别一个为Servertim.java但编译通不过,说是少“;”,可我也没发现什么地方少啊!
public class ServerTimout extends Exception{
private String reason;
private int port;
public ServerTimout(String reason,int port){
this.reason=reason;
this.port=port;
//if(port==80)throw new ("没法连接端口:",80)
}
public String getreason(){
return reason;
}
public int getport(){
return port;
}
}
-------------------
public class Servertim{
public void timout(int port) throws ServerTimout{
if(port==80)throw new ServerTimout("没法连接端口:",80)
}
public static void main(String args[]){
Servertim a=new Servertim();
try{
a.timout(80);
}catch(Servertim b){
System.out.println(b.getreason());
}
}
}
请网友帮看看!
public class ServerTimout extends Exception{
private String reason;
private int port;
public ServerTimout(String reason,int port){
this.reason=reason;
this.port=port;
//if(port==80)throw new ("没法连接端口:",80)
}
public String getreason(){
return reason;
}
public int getport(){
return port;
}
}
-------------------
public class Servertim{
public void timout(int port) throws ServerTimout{
if(port==80)throw new ServerTimout("没法连接端口:",80)
}
public static void main(String args[]){
Servertim a=new Servertim();
try{
a.timout(80);
}catch(Servertim b){
System.out.println(b.getreason());
}
}
}
请网友帮看看!
解决方案 »
- 如何用ParserCallback解析HTML文档,并去除文档中的空格符号
- Collections.sort()出现“使用了未经检查或不安全的操作”
- java替换字符
- 字符串转二进制,请教高人!!
- effective java item5的pop可不可以这样?
- -----windows下CVS的配置和使用问题(不知道应该在哪里问)------
- 如何使用jdk开发java程序(初级)100分,在线给分
- 关于Socket编程中超时处理的问题困惑,请大家近来帮帮忙!
- 完整的使用Microsoft提供的JDBC接口的例子,编译执行都通过,为什么就是没有结果?
- 多线程中,会在system.out.println(name+"----"+age)运行到一半的时候被其他线程抢走执行权吗
- 求0.1的2次方
- 使用抽象类写一个shape类出错了。错误信息:需要 ".class",不是语句,需要 ";"等
if(port==80)throw new ServerTimout("没法连接端口:",80)少了";"
命名有点不行!!!!
并且将catch(Servertim b) 改为 catch(ServerTimout e)