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

  • Home
  • SEARCH
  • 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 6878793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:46:03+00:00 2026-05-27T04:46:03+00:00

In scala.collection , there are two very similar objects JavaConversions and JavaConverters . What

  • 0

In scala.collection, there are two very similar objects JavaConversions and JavaConverters.

  • What is the difference between these two objects?
  • Why do they both exist?
  • When do I want to use one vs. the other?
  • 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-27T04:46:03+00:00Added an answer on May 27, 2026 at 4:46 am

    EDIT: Java Conversions got @deprecated in Scala 2.13.0. Use scala.jdk.CollectionConverters instead.

    JavaConversions provide a series of implicit methods that convert between a Java collection and the closest corresponding Scala collection, and vice versa. This is done by creating wrappers that implement either the Scala interface and forward the calls to the underlying Java collection, or the Java interface, forwarding the calls to the underlying Scala collection.

    JavaConverters uses the pimp-my-library pattern to “add” the asScala method to the Java collections and the asJava method to the Scala collections, which return the appropriate wrappers discussed above. It is newer (since version 2.8.1) than JavaConversions (since 2.8) and makes the conversion between Scala and Java collection explicit. Contrary to what David writes in his answer, I’d recommend you make it a habit to use JavaConverters as you’ll be much less likely to write code that makes a lot of implicit conversions, as you can control the only spot where that will happen: where you write .asScala or .asJava.

    Here’s the conversion methods that JavaConverters provide:

    Pimped Type                            | Conversion Method   | Returned Type
    =================================================================================================
    scala.collection.Iterator              | asJava              | java.util.Iterator
    scala.collection.Iterator              | asJavaEnumeration   | java.util.Enumeration
    scala.collection.Iterable              | asJava              | java.lang.Iterable
    scala.collection.Iterable              | asJavaCollection    | java.util.Collection
    scala.collection.mutable.Buffer        | asJava              | java.util.List
    scala.collection.mutable.Seq           | asJava              | java.util.List
    scala.collection.Seq                   | asJava              | java.util.List
    scala.collection.mutable.Set           | asJava              | java.util.Set
    scala.collection.Set                   | asJava              | java.util.Set
    scala.collection.mutable.Map           | asJava              | java.util.Map
    scala.collection.Map                   | asJava              | java.util.Map
    scala.collection.mutable.Map           | asJavaDictionary    | java.util.Dictionary
    scala.collection.mutable.ConcurrentMap | asJavaConcurrentMap | java.util.concurrent.ConcurrentMap
    —————————————————————————————————————————————————————————————————————————————————————————————————
    java.util.Iterator                     | asScala             | scala.collection.Iterator
    java.util.Enumeration                  | asScala             | scala.collection.Iterator
    java.lang.Iterable                     | asScala             | scala.collection.Iterable
    java.util.Collection                   | asScala             | scala.collection.Iterable
    java.util.List                         | asScala             | scala.collection.mutable.Buffer
    java.util.Set                          | asScala             | scala.collection.mutable.Set
    java.util.Map                          | asScala             | scala.collection.mutable.Map
    java.util.concurrent.ConcurrentMap     | asScala             | scala.collection.mutable.ConcurrentMap
    java.util.Dictionary                   | asScala             | scala.collection.mutable.Map
    java.util.Properties                   | asScala             | scala.collection.mutable.Map[String, String]
    

    To use the conversions directly from Java, though, you’re better off calling methods from JavaConversions directly; e.g.:

    List<String> javaList = new ArrayList<String>(Arrays.asList("a", "b", "c"));
    System.out.println(javaList); // [a, b, c]
    Buffer<String> scalaBuffer = JavaConversions.asScalaBuffer(javaList);
    System.out.println(scalaBuffer); // Buffer(a, b, c)
    List<String> javaListAgain = JavaConversions.bufferAsJavaList(scalaBuffer);
    System.out.println(javaList == javaListAgain); // true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are other questions such as Scala: What is the difference between Traversable and
Is there an implicit method to convert scala.collection.mutable.StringBuilder to java.lang.StringBuilder? I am using a
This can be done using a converter wrapper: import scala.collection.JavaConversions._ object ListConverter { def
Why is there a lack of consistency between Sets and Lists in Scala Collections
scala> val m = Map(1 -> 2) m: scala.collection.immutable.Map[Int,Int] = Map(1 -> 2) scala>
I am having problems using the update method of scala.collection.immutable.HashMap.I don't see the reason
I have a class that I would like to use in a scala.collection.mutable.PriorityQueue, but
Methods like aggregate on scala.collection.parallel.immutable.ParIterableLike process using Threads. Does that mean I shouldn't be
Language FAQ says import scala.collection.mutable.{_, Map => _, Set => _} should import all
I've got some code that references scala.collection.jcl written against Scala 2.7.7. I'm now trying

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.