If we use a valid URL instead of wow (say, http://example.com/wow), the result is http://example.com/3, which is correct: The 2 replaces the wow, and the 3 replaces the 2. This is how relative URLs work.
If you want to stack them and get http://example.com/wow/2/3, you need / at the end of wow and 2:
import java.net.*;
class NetTest {
public static void main(String[] args) throws Exception{
URL url;
url = new URL(new URL(new URL("http://example.com/wow/"), "2/"), "3");
// --------------------------------------------------^------^
System.out.println(url);
}
}
3
solved which resource represents the object: