Příklad
public
static
class
ClassA {
private
URL url =
new
URL(
"http://example.com"
);
private
URL url2;
public
void
methodA {
try
{
if
(url.equals(url2)){
//...
}
}
catch
( Exception e ) {
//...
}
}
}
Řešení
Použijte objekty URI místo objektů URL.
public
static
class
ClassA {
private
URI uri =
new
URI(
"http://example.com"
);
private
URI uri2;
public
void
methodA {
try
{
if
(uri.equals(uri2)){
//...
}
}
catch
( Exception e ) {
//...
}
}
}