3

If it is possible, how would I loop through a ListBuffer from within java. initialization of the ListBuffer (in scala)

var newModVersions: ListBuffer[NewModVersionEntry] = new ListBuffer[NewModVersionEntry]()

current smart for loop (in java)

for (VersionCheckHandler.NewModVersionEntry entry : XplosionCoreBL.newModVersions())

1 Answer 1

5

You can use JavaConversions for that:

import scala.collection.JavaConversions;
//...
for (YourEntryClass entry : JavaConversions.asJavaIterable(yourListBuffer)) {

(I've switched to placeholder types and vars, since otherwise the example would be less readable)

See this answer to an "inverse" question for general info, and this question+answer for an explanation of the design approach taken in the Scala library.

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.