class Wish{
val s = "Hello! User. Wish you a Great day."
}
object Wish{
def main(args: Array[String]){
val w = new Wish()
println("Value - " + w.s )
}
}
Java classes can be used in Scala. Similarly, can Scala classes be used in Java?
Yes. If you want to do this, there are a few things you might want to remember:
@BeanProperty
annotation to fields.ClassName.of
where Scala uses .apply
. Those you have to provide by hand, if you want to provide that service. If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With