Hi all
When compiling my program
Following errors getted:-
1.unreported exception java.net.UnknownHostException; must be caught or declared to be thrown
InetAddress inet = InetAddress.getByName("www.davidreilly.com");
2.exception java.net.MalformedURLException is never thrown in body of corresponding try statement
catch (MalformedURLException e){}
This is the part of my code in which errors occur
try {
InetAddress inet = InetAddress.getByName("www.davidreilly.com");
System.out.println ("IP : " + inet.getHostAddress());
}
catch (MalformedURLException e){}
Please help me to correct and why unreported exception java.net.UnknownHostException; must be caught or declared to be thrown if I dont use try and catch statements
Thanks in advance.