Is there any merit (coding style, OOP best practice, etc.) in working with an instance of java.net.URL
as opposed to java.lang.String
when I can be reasonably certain that a URL is valid anyway (perhaps I've specified it statically in a properties file) and I will just be working with it in its string form anyway (for example printing it in a JSP file)?
java.net.URL
's equals is broken. You should use java.net.URI
. You should pass objects around whenever possible rather than Strings. It saves programmer errors, for example getting method parameters the wrong way round - the compiler won't pick it up if they're both Strings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With