0

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.

1 Answer 1

2

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";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.