Topic: 请教高手,为什么编译通不过?

  Print this page

1.请教高手,为什么编译通不过? Copy to clipboard
Posted by: 雪中行
Posted on: 2005-03-12 16:47

import java.net.URL;
import java.net.MalFormedURLException;

class getURLinfo
{
public static void main(String args [])
{
URL url=null;
try
{url=new URL("http://www.edu.cn/20050311/3130828.shtml");}
catch(MalformedURLException e)
{System.out.println("MalformedURLException:"+e);}
System.out.println("Protocol:"+url.getProtocol());
System.out.println("Host:"+url.getHost());
System.out.println("Port:"+url.getPort());
System.out.println("File:"+url.getFile());
System.out.println("Ref:"+url.getRef());
}}}

2.Re:请教高手,为什么编译通不过? [Re: 雪中行] Copy to clipboard
Posted by: kimmy
Posted on: 2005-03-12 22:45

catch(MalformedURLException e)
这一句是不是后面少了一对括号阿
catch(MalformedURLException e){}
这样写?

3.Re:请教高手,为什么编译通不过? [Re: 雪中行] Copy to clipboard
Posted by: ma1673
Posted on: 2005-03-13 15:28

有道理啊!

4.Re:请教高手,为什么编译通不过? [Re: 雪中行] Copy to clipboard
Posted by: 雪中行
Posted on: 2005-03-13 17:48

不对呀,还是编译不过。
而且程序里有{}

5.Re:请教高手,为什么编译通不过? [Re: 雪中行] Copy to clipboard
Posted by: kimmy
Posted on: 2005-03-13 23:17

编译的时候出现什么错误?

6.Re:请教高手,为什么编译通不过? [Re: 雪中行] Copy to clipboard
Posted by: tianyake
Posted on: 2005-03-13 23:21

你太不小心了,
import java.net.URL;
import java.net.MalformedURLException;

class getURLinfo
{
public static void main(String args [])
{
URL url=null;
try
{
url=new URL("http://www.edu.cn/20050311/3130828.shtml");
}
catch(MalformedURLException e)
{
System.out.println("MalformedURLException:"+e);
}
System.out.println("Protocol:"+url.getProtocol());
System.out.println("Host:"+url.getHost());
System.out.println("Port:"+url.getPort());
System.out.println("File:"+url.getFile());
System.out.println("Ref:"+url.getRef());
}
}
这样就行了。在jbuilder2005运行正常

7.Re:请教高手,为什么编译通不过? [Re: 雪中行] Copy to clipboard
Posted by: ma1673
Posted on: 2005-03-14 09:54

多了一个括号啊

8.Re:请教高手,为什么编译通不过? [Re: 雪中行] Copy to clipboard
Posted by: ma1673
Posted on: 2005-03-14 09:59

"getUrlInfo.java": cannot resolve symbol: class MalformedURLException in class test1.getURLinfo at line 13, column 7
为什么我的Jbuilder 9有这样的提示呢?

9.Re:请教高手,为什么编译通不过? [Re: 雪中行] Copy to clipboard
Posted by: lenkeny
Posted on: 2005-03-14 23:46

}}}多了一个大括号


   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