Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conversion from Scala String to java.lang.String

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

like image 302
Arush Kharbanda Avatar asked Sep 14 '26 00:09

Arush Kharbanda


1 Answers

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
  // ...
}
like image 106
Daniel Olszewski Avatar answered Sep 15 '26 14:09

Daniel Olszewski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!