在JAVA中出现cannot resolve symbol method URL (java.lang.String)
GetUrl.java:8:cannotresolvesymbolsymbol:methodURL(java.lang.String)location:classGetU...
GetUrl.java:8: cannot resolve symbol
symbol : method URL (java.lang.String)
location: class GetUrl
URL lib=URL(" http://dir.sohu.com:80/company/electronics/index.ht
ml");
^
1 error 我的程序是:import java.net.*;
import java.io.*;
class GetUrl
{
public static void main(String[] args) throws MalformedURLException
{
URL lib=URL(" http://dir.sohu.com:80/company/electronics/index.html");
System.out.println("协议"+lib.getProtocol());
System.out.println("端口"+lib.getPort());
System.out.println("主机名"+lib.getHost());
System.out.println("文件"+lib.getFile());
System.out.println("地址"+lib.toExternalForm());
}} 展开
symbol : method URL (java.lang.String)
location: class GetUrl
URL lib=URL(" http://dir.sohu.com:80/company/electronics/index.ht
ml");
^
1 error 我的程序是:import java.net.*;
import java.io.*;
class GetUrl
{
public static void main(String[] args) throws MalformedURLException
{
URL lib=URL(" http://dir.sohu.com:80/company/electronics/index.html");
System.out.println("协议"+lib.getProtocol());
System.out.println("端口"+lib.getPort());
System.out.println("主机名"+lib.getHost());
System.out.println("文件"+lib.getFile());
System.out.println("地址"+lib.toExternalForm());
}} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询