Pooya
Pooya

Reputation: 4481

Fastest way to convert Scala array to Java array

I have a method in Java with this signature void setActiveProfiles(String... profiles), and in Java I can pass an array of string to this method. I want to call the method and pass it an Array[String], but I got Type mismatch error. And my question is what is the best and optimal way to convert Scala array to Java array?

This is the body of compilation error:

type mismatch;
 found   : Array[String]
 required: String

Upvotes: 5

Views: 2796

Answers (1)

Pooya
Pooya

Reputation: 4481

I've found the answer and I've tested it, call method as setActiveProfiles(array:_*)

Upvotes: 3

Related Questions