Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (10.2k points)

How is it possible to convert a String to a URL in Java (Android)? i.e.:

String myUrl = "https://intellipaat.com";

myUri = ???;

1 Answer

0 votes
by (119k points)
edited by

'URL' is a class. Use 'new' to create a new instance of the class URL and pass the string myUrl as a parameter to the constructor.

String myUrl = "https://intellipaat.com";

URL myURL = new URL(myUrl);

If you want to learn Java, then check out this Java Certification program by Intellipaat.

Related questions

0 votes
1 answer
asked Sep 15, 2019 in Java by Suresh (3.4k points)
0 votes
1 answer
asked Jul 17, 2019 in Java by adam96 (800 points)
0 votes
1 answer
0 votes
1 answer
asked Oct 17, 2019 in Java by Shubham (3.9k points)
0 votes
1 answer

Browse Categories

...