2

How do i convert a Scala string to a java.lang String.

I have to create a java.net.URL Object from a scala String. How do i do the conversion from a scala String to java.lang.String to pass to the URL constructor

1 Answer 1

13

You don't need to do any conversion. Simply pass a String to the URL constructor.

If you look at the scala.Predef String definition you will see this is exactly the same type.

package scala
object Predef extends scala.LowPriorityImplicits {
  // ...
  type String = java.lang.String
  // ...
}
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.