In the following code:
I haven't explicitly specified the Port No. in the URL above, but is it so "that port nos. ain't necessary"
Also the above program gives me the output "-1" so
1. Is there a default port automatically assigned by Java?(i heard it is "80")
2. If YES then why did the output render(display) "-1".
Code:
public class URLDemo {
public static void main(String args[])throws Exception {
URL u=new URL("http://www.google.com");
System.out.println("Port No : "+u.getPort());
}
}
Also the above program gives me the output "-1" so
1. Is there a default port automatically assigned by Java?(i heard it is "80")
2. If YES then why did the output render(display) "-1".
Comment