javascalascala-java-interoplistbuffer

Add element to scala ListBuffer in java


If it is possible what would be the easiest way of adding an element to a scala ListBuffer from within java.

this is the scala ListBuffer (in scala)

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

and this is what I want to add (in java)

XplosionCoreBL.newModVersion().add(new NewModVersionEntry(name, latestVersion, latestMCVersion, isCritical, description));

Solution

  • XplosionCoreBL.newModVersion().$plus$eq(new NewModVersionEntry(name, latestVersion, latestMCVersion, isCritical, description));
    

    In Java, $plus$eq corresponds to the += (append single element) method of ListBuffer.