Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6947965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:45:39+00:00 2026-05-27T13:45:39+00:00

Starting with Scala version 2.9 there exists a handy converter to convert from java.util.List

  • 0

Starting with Scala version 2.9 there exists a handy converter to convert from java.util.List and other collections to Scala’s data structures by writing something like this:

import scala.collection.JavaConverters._
def scalaVersion = callJavaMethod.asScala

This is a lovely little feature, as it allows one to exploit the advantages of Scala when interacting with existing Java code.

However, I am uncertain about the involved time and space complexity and could not find anything in the official documentation, hence, the following question:

Where can I get information on the complexity (time and space) of the JavaConverters?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:45:40+00:00Added an answer on May 27, 2026 at 1:45 pm

    Various JavaConverters classes are using Adapter pattern to wrap original Java collection (underlying) and provide Scala interface. Thus both converting and accessing converted collections is constant in time (O(1)) introducing only minor overhead.

    For instance this is the full source code of JListWrapper:

    case class JListWrapper[A](val underlying : java.util.List[A]) extends mutable.Buffer[A] {
        def length = underlying.size
        override def isEmpty = underlying.isEmpty
        override def iterator : Iterator[A] = underlying.iterator
        def apply(i : Int) = underlying.get(i)
        def update(i : Int, elem : A) = underlying.set(i, elem)
        def +=:(elem : A) = { underlying.subList(0, 0).add(elem) ; this } 
        def +=(elem : A): this.type = { underlying.add(elem); this }
        def insertAll(i : Int, elems : Traversable[A]) = { val ins = underlying.subList(0, i) ;  elems.seq.foreach(ins.add(_)) }
        def remove(i : Int) = underlying.remove(i)
        def clear = underlying.clear
        def result = this
    }
    

    Also note that converting Java collection to Scala and then back to Java yields the original collection, not double-wrapper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Starting from ASP.NET MVC Preview 3, HTML.Button ( and other related HTML controls) are
i'm starting with Scala and i found this a little weird. In java i
I'm using Scala 2.9.0.final on Ubuntu 11.04. Starting scala from the command line takes
I am starting to I am learning scala, and trying to build some simple
I'm trying to get started with Scala and cannot get out of the starting
Starting with the following LINQ query: from a in things where a.Id == b.Id
I'm starting with Scala + Android (and using the sbt android plugin). I'm trying
I'm starting to understand Scala and I like it a lot. How can you
I am starting to learn Scala and I will do a simple cross compiler.
A have lift app starting ssh daemon in Boot.scala. Here is the problem: when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.