Reputation: 9
Can I use a variable in the following code?
String Var = "\"http://dl.dropbox.com/u/44966/xml%20roma.xml\"";
URL url1 = new URL(Var);
Is it only allowed to use a literal string, as in the following line?
URL url1 = new URL("http://dl.dropbox.com/u/44966/xml%20roma.xml");
In my application it is imperative that I use a variable.
Upvotes: 0
Views: 1951
Reputation: 5099
As long as the constructor of the URL class accepts a String object, you can pass it directly or through the usage of a variable.
But your string variable, to be equivalent with the example string you present, should be like this:
String Var = "http://dl.dropbox.com/u/44966/xml%20roma.xml";
Upvotes: 2