Packages

o

scala.collection

JavaConverters

object JavaConverters extends AsJavaConverters with AsScalaConverters

A variety of decorators that enable converting between Scala and Java collections using extension methods, asScala and asJava.

The extension methods return adapters for the corresponding API.

The following conversions are supported via asScala and asJava:

scala.collection.Iterable       <=> java.lang.Iterable
scala.collection.Iterator       <=> java.util.Iterator
scala.collection.mutable.Buffer <=> java.util.List
scala.collection.mutable.Set    <=> java.util.Set
scala.collection.mutable.Map    <=> java.util.Map
scala.collection.concurrent.Map <=> java.util.concurrent.ConcurrentMap

The following conversions are supported via asScala and through specially-named extension methods to convert to Java collections, as shown:

scala.collection.Iterable    <=> java.util.Collection   (via asJavaCollection)
scala.collection.Iterator    <=> java.util.Enumeration  (via asJavaEnumeration)
scala.collection.mutable.Map <=> java.util.Dictionary   (via asJavaDictionary)

In addition, the following one-way conversions are provided via asJava:

scala.collection.Seq         => java.util.List
scala.collection.mutable.Seq => java.util.List
scala.collection.Set         => java.util.Set
scala.collection.Map         => java.util.Map

The following one way conversion is provided via asScala:

java.util.Properties => scala.collection.mutable.Map

In all cases, converting from a source type to a target type and back again will return the original source object. For example:

import scala.collection.JavaConverters._

val source = new scala.collection.mutable.ListBuffer[Int]
val target: java.util.List[Int] = source.asJava
val other: scala.collection.mutable.Buffer[Int] = target.asScala
assert(source eq other)

Alternatively, the conversion methods have descriptive names and can be invoked explicitly.

scala> val vs = java.util.Arrays.asList("hi", "bye")
vs: java.util.List[String] = [hi, bye]

scala> val ss = asScalaIterator(vs.iterator)
ss: Iterator[String] = <iterator>

scala> .toList
res0: List[String] = List(hi, bye)

scala> val ss = asScalaBuffer(vs)
ss: scala.collection.mutable.Buffer[String] = Buffer(hi, bye)
Annotations
@deprecated
Deprecated

(Since version 2.13.0) Use scala.jdk.CollectionConverters instead

Source
JavaConverters.scala
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. JavaConverters
  2. AsScalaConverters
  3. AsJavaConverters
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. class AsJava[A] extends AnyRef

    Generic class containing the asJava converter method

  2. class AsJavaCollection[A] extends AnyRef

    Generic class containing the asJavaCollection converter method

  3. class AsJavaDictionary[K, V] extends AnyRef

    Generic class containing the asJavaDictionary converter method

  4. class AsJavaEnumeration[A] extends AnyRef

    Generic class containing the asJavaEnumeration converter method

  5. class AsScala[A] extends AnyRef

    Generic class containing the asScala converter method

Value Members

  1. final def !=(arg0: Any): Boolean

    Test two objects for inequality.

    Test two objects for inequality.

    returns

    true if !(this == that), false otherwise.

    Definition Classes
    AnyRef → Any
  2. final def ##: Int

    Equivalent to x.hashCode except for boxed numeric types and null.

    Equivalent to x.hashCode except for boxed numeric types and null. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them. For null returns a hashcode where null.hashCode throws a NullPointerException.

    returns

    a hash value consistent with ==

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    The expression x == that is equivalent to if (x eq null) that eq null else x.equals(that).

    The expression x == that is equivalent to if (x eq null) that eq null else x.equals(that).

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Forces the compiler to treat the receiver object as having type T0, even though doing so may violate type safety.

    Forces the compiler to treat the receiver object as having type T0, even though doing so may violate type safety.

    This method is useful when you believe you have type information the compiler doesn't, and it also isn't possible to check the type at runtime. In such situations, skipping type safety is the only option.

    It is platform dependent whether asInstanceOf has any effect at runtime. It might do a runtime type test on the erasure of T0, insert a conversion (such as boxing/unboxing), fill in a default value, or do nothing at all.

    In particular, asInstanceOf is not a type test. It does **not** mean:

    this match {
     case x: T0 => x
     case _     => throw ClassCastException("...")

    Use pattern matching or isInstanceOf for type testing instead.

    Situations where asInstanceOf is useful:

    • when flow analysis fails to deduce T0 automatically
    • when down-casting a type parameter or an abstract type member (which cannot be checked at runtime due to type erasure) If there is any doubt and you are able to type test instead, you should do so.

    Be careful of using asInstanceOf when T0 is a primitive type. When T0 is primitive, asInstanceOf may insert a conversion instead of a type test. If your intent is to convert, use a toT method (x.toChar, x.toByte, etc.).

    returns

    the receiver object.

    Definition Classes
    Any
    Exceptions thrown

    ClassCastException if the receiver is not an instance of the erasure of T0, if that can be checked on this platform

  5. def asJava[K, V](m: concurrent.Map[K, V]): ConcurrentMap[K, V]

    Converts a Scala mutable concurrent.Map to a Java ConcurrentMap.

    Converts a Scala mutable concurrent.Map to a Java ConcurrentMap.

    The returned Java ConcurrentMap is backed by the provided Scala concurrent.Map and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala concurrent.Map was previously obtained from an implicit or explicit call of asScala then the original Java ConcurrentMap will be returned.

    m

    The Scala concurrent.Map to be converted.

    returns

    A Java ConcurrentMap view of the argument.

    Definition Classes
    AsJavaConverters
  6. def asJava[K, V](m: Map[K, V]): java.util.Map[K, V]

    Converts a Scala Map to a Java Map.

    Converts a Scala Map to a Java Map.

    The returned Java Map is backed by the provided Scala Map and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala Map was previously obtained from an implicit or explicit call of asScala then the original Java Map will be returned.

    m

    The Scala Map to be converted.

    returns

    A Java Map view of the argument.

    Definition Classes
    AsJavaConverters
  7. def asJava[K, V](m: mutable.Map[K, V]): java.util.Map[K, V]

    Converts a Scala mutable Map to a Java Map.

    Converts a Scala mutable Map to a Java Map.

    The returned Java Map is backed by the provided Scala Map and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala Map was previously obtained from an implicit or explicit call of asScala then the original Java Map will be returned.

    m

    The Scala mutable Map to be converted.

    returns

    A Java Map view of the argument.

    Definition Classes
    AsJavaConverters
  8. def asJava[A](s: Set[A]): java.util.Set[A]

    Converts a Scala Set to a Java Set.

    Converts a Scala Set to a Java Set.

    The returned Java Set is backed by the provided Scala Set and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala Set was previously obtained from an implicit or explicit call of asScala then the original Java Set will be returned.

    s

    The Scala Set to be converted.

    returns

    A Java Set view of the argument.

    Definition Classes
    AsJavaConverters
  9. def asJava[A](s: mutable.Set[A]): java.util.Set[A]

    Converts a Scala mutable Set to a Java Set.

    Converts a Scala mutable Set to a Java Set.

    The returned Java Set is backed by the provided Scala Set and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala Set was previously obtained from an implicit or explicit call of asScala then the original Java Set will be returned.

    s

    The Scala mutable Set to be converted.

    returns

    A Java Set view of the argument.

    Definition Classes
    AsJavaConverters
  10. def asJava[A](s: Seq[A]): java.util.List[A]

    Converts a Scala Seq to a Java List.

    Converts a Scala Seq to a Java List.

    The returned Java List is backed by the provided Scala Seq and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala Seq was previously obtained from an implicit or explicit call of asScala then the original Java List will be returned.

    s

    The Scala Seq to be converted.

    returns

    A Java List view of the argument.

    Definition Classes
    AsJavaConverters
  11. def asJava[A](s: mutable.Seq[A]): java.util.List[A]

    Converts a Scala mutable Seq to a Java List.

    Converts a Scala mutable Seq to a Java List.

    The returned Java List is backed by the provided Scala Seq and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala Seq was previously obtained from an implicit or explicit call of asScala then the original Java List will be returned.

    s

    The Scala Seq to be converted.

    returns

    A Java List view of the argument.

    Definition Classes
    AsJavaConverters
  12. def asJava[A](b: Buffer[A]): java.util.List[A]

    Converts a Scala mutable Buffer to a Java List.

    Converts a Scala mutable Buffer to a Java List.

    The returned Java List is backed by the provided Scala Buffer and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala Buffer was previously obtained from an implicit or explicit call of asScala then the original Java List will be returned.

    b

    The Scala Buffer to be converted.

    returns

    A Java List view of the argument.

    Definition Classes
    AsJavaConverters
  13. def asJava[A](i: Iterable[A]): java.lang.Iterable[A]

    Converts a Scala Iterable to a Java Iterable.

    Converts a Scala Iterable to a Java Iterable.

    The returned Java Iterable is backed by the provided Scala Iterable and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala Iterable was previously obtained from an implicit or explicit call of asScala then the original Java Iterable will be returned.

    i

    The Scala Iterable to be converted.

    returns

    A Java Iterable view of the argument.

    Definition Classes
    AsJavaConverters
  14. def asJava[A](i: Iterator[A]): java.util.Iterator[A]

    Converts a Scala Iterator to a Java Iterator.

    Converts a Scala Iterator to a Java Iterator.

    The returned Java Iterator is backed by the provided Scala Iterator and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala Iterator was previously obtained from an implicit or explicit call of asScala then the original Java Iterator will be returned.

    i

    The Scala Iterator to be converted.

    returns

    A Java Iterator view of the argument.

    Definition Classes
    AsJavaConverters
  15. def asJavaCollection[A](i: Iterable[A]): Collection[A]

    Converts a Scala Iterable to an immutable Java Collection.

    Converts a Scala Iterable to an immutable Java Collection.

    If the Scala Iterable was previously obtained from an implicit or explicit call of asScala then the original Java Collection will be returned.

    i

    The Scala Iterable to be converted.

    returns

    A Java Collection view of the argument.

    Definition Classes
    AsJavaConverters
  16. implicit def asJavaCollectionConverter[A](i: Iterable[A]): AsJavaCollection[A]

    Adds an asJavaCollection method that implicitly converts a Scala Iterable to an immutable Java Collection.

    Adds an asJavaCollection method that implicitly converts a Scala Iterable to an immutable Java Collection.

    See also

    asJavaCollection

  17. def asJavaDictionary[K, V](m: mutable.Map[K, V]): Dictionary[K, V]

    Converts a Scala mutable Map to a Java Dictionary.

    Converts a Scala mutable Map to a Java Dictionary.

    The returned Java Dictionary is backed by the provided Scala Dictionary and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala Map was previously obtained from an implicit or explicit call of asScala then the original Java Dictionary will be returned.

    m

    The Scala Map to be converted.

    returns

    A Java Dictionary view of the argument.

    Definition Classes
    AsJavaConverters
  18. implicit def asJavaDictionaryConverter[K, V](m: mutable.Map[K, V]): AsJavaDictionary[K, V]

    Adds an asJavaDictionary method that implicitly converts a Scala mutable Map to a Java Dictionary.

    Adds an asJavaDictionary method that implicitly converts a Scala mutable Map to a Java Dictionary.

    See also

    asJavaDictionary

  19. def asJavaEnumeration[A](i: Iterator[A]): java.util.Enumeration[A]

    Converts a Scala Iterator to a Java Enumeration.

    Converts a Scala Iterator to a Java Enumeration.

    The returned Java Enumeration is backed by the provided Scala Iterator and any side-effects of using it via the Java interface will be visible via the Scala interface and vice versa.

    If the Scala Iterator was previously obtained from an implicit or explicit call of asScala then the original Java Enumeration will be returned.

    i

    The Scala Iterator to be converted.

    returns

    A Java Enumeration view of the argument.

    Definition Classes
    AsJavaConverters
  20. implicit def asJavaEnumerationConverter[A](i: Iterator[A]): AsJavaEnumeration[A]

    Adds an asJavaEnumeration method that implicitly converts a Scala Iterator to a Java Enumeration.

    Adds an asJavaEnumeration method that implicitly converts a Scala Iterator to a Java Enumeration.

    See also

    asJavaEnumeration

  21. implicit def asJavaIterableConverter[A](i: Iterable[A]): AsJava[java.lang.Iterable[A]]

    Adds an asJava method that implicitly converts a Scala Iterable to a Java Iterable.

    Adds an asJava method that implicitly converts a Scala Iterable to a Java Iterable.

    See also

    asJavaIterable

  22. implicit def asJavaIteratorConverter[A](i: Iterator[A]): AsJava[java.util.Iterator[A]]

    Adds an asJava method that implicitly converts a Scala Iterator to a Java Iterator.

    Adds an asJava method that implicitly converts a Scala Iterator to a Java Iterator.

    See also

    asJavaIterator

  23. def asScala(p: Properties): mutable.Map[String, String]

    Converts a Java Properties to a Scala mutable Map[String, String].

    Converts a Java Properties to a Scala mutable Map[String, String].

    The returned Scala Map[String, String] is backed by the provided Java Properties and any side-effects of using it via the Scala interface will be visible via the Java interface and vice versa.

    p

    The Java Properties to be converted.

    returns

    A Scala mutable Map[String, String] view of the argument.

    Definition Classes
    AsScalaConverters
  24. def asScala[K, V](d: Dictionary[K, V]): mutable.Map[K, V]

    Converts a Java Dictionary to a Scala mutable Map.

    Converts a Java Dictionary to a Scala mutable Map.

    The returned Scala Map is backed by the provided Java Dictionary and any side-effects of using it via the Scala interface will be visible via the Java interface and vice versa.

    If the Java Dictionary was previously obtained from an implicit or explicit call of asJavaDictionary then the original Scala Map will be returned.

    d

    The Java Dictionary to be converted.

    returns

    A Scala mutable Map view of the argument.

    Definition Classes
    AsScalaConverters
  25. def asScala[K, V](m: ConcurrentMap[K, V]): concurrent.Map[K, V]

    Converts a Java ConcurrentMap to a Scala mutable ConcurrentMap.

    Converts a Java ConcurrentMap to a Scala mutable ConcurrentMap.

    The returned Scala ConcurrentMap is backed by the provided Java ConcurrentMap and any side-effects of using it via the Scala interface will be visible via the Java interface and vice versa.

    If the Java ConcurrentMap was previously obtained from an implicit or explicit call of asJava then the original Scala ConcurrentMap will be returned.

    m

    The Java ConcurrentMap to be converted.

    returns

    A Scala mutable ConcurrentMap view of the argument.

    Definition Classes
    AsScalaConverters
  26. def asScala[K, V](m: java.util.Map[K, V]): mutable.Map[K, V]

    Converts a Java Map to a Scala mutable Map.

    Converts a Java Map to a Scala mutable Map.

    The returned Scala Map is backed by the provided Java Map and any side-effects of using it via the Scala interface will be visible via the Java interface and vice versa.

    If the Java Map was previously obtained from an implicit or explicit call of asJava then the original Scala Map will be returned.

    If the wrapped map is synchronized (e.g. from java.util.Collections.synchronizedMap), it is your responsibility to wrap all non-atomic operations with underlying.synchronized. This includes get, as java.util.Map's API does not allow for an atomic get when null values may be present.

    m

    The Java Map to be converted.

    returns

    A Scala mutable Map view of the argument.

    Definition Classes
    AsScalaConverters
  27. def asScala[A](s: java.util.Set[A]): mutable.Set[A]

    Converts a Java Set to a Scala mutable Set.

    Converts a Java Set to a Scala mutable Set.

    The returned Scala Set is backed by the provided Java Set and any side-effects of using it via the Scala interface will be visible via the Java interface and vice versa.

    If the Java Set was previously obtained from an implicit or explicit call of asJava then the original Scala Set will be returned.

    s

    The Java Set to be converted.

    returns

    A Scala mutable Set view of the argument.

    Definition Classes
    AsScalaConverters
  28. def asScala[A](l: java.util.List[A]): Buffer[A]

    Converts a Java List to a Scala mutable Buffer.

    Converts a Java List to a Scala mutable Buffer.

    The returned Scala Buffer is backed by the provided Java List and any side-effects of using it via the Scala interface will be visible via the Java interface and vice versa.

    If the Java List was previously obtained from an implicit or explicit call of asJava then the original Scala Buffer will be returned.

    l

    The Java List to be converted.

    returns

    A Scala mutable Buffer view of the argument.

    Definition Classes
    AsScalaConverters
  29. def asScala[A](c: Collection[A]): Iterable[A]

    Converts a Java Collection to a Scala Iterable.

    Converts a Java Collection to a Scala Iterable.

    If the Java Collection was previously obtained from an implicit or explicit call of asJavaCollection then the original Scala Iterable will be returned.

    c

    The Java Collection to be converted.

    returns

    A Scala Iterable view of the argument.

    Definition Classes
    AsScalaConverters
  30. def asScala[A](i: java.lang.Iterable[A]): Iterable[A]

    Converts a Java Iterable to a Scala Iterable.

    Converts a Java Iterable to a Scala Iterable.

    The returned Scala Iterable is backed by the provided Java Iterable and any side-effects of using it via the Scala interface will be visible via the Java interface and vice versa.

    If the Java Iterable was previously obtained from an implicit or explicit call of asJava then the original Scala Iterable will be returned.

    i

    The Java Iterable to be converted.

    returns

    A Scala Iterable view of the argument.

    Definition Classes
    AsScalaConverters
  31. def asScala[A](e: java.util.Enumeration[A]): Iterator[A]

    Converts a Java Enumeration to a Scala Iterator.

    Converts a Java Enumeration to a Scala Iterator.

    The returned Scala Iterator is backed by the provided Java Enumeration and any side-effects of using it via the Scala interface will be visible via the Java interface and vice versa.

    If the Java Enumeration was previously obtained from an implicit or explicit call of asJavaEnumeration then the original Scala Iterator will be returned.

    e

    The Java Enumeration to be converted.

    returns

    A Scala Iterator view of the argument.

    Definition Classes
    AsScalaConverters
  32. def asScala[A](i: java.util.Iterator[A]): Iterator[A]

    Converts a Java Iterator to a Scala Iterator.

    Converts a Java Iterator to a Scala Iterator.

    The returned Scala Iterator is backed by the provided Java Iterator and any side-effects of using it via the Scala interface will be visible via the Java interface and vice versa.

    If the Java Iterator was previously obtained from an implicit or explicit call of asJava then the original Scala Iterator will be returned.

    i

    The Java Iterator to be converted.

    returns

    A Scala Iterator view of the argument.

    Definition Classes
    AsScalaConverters
  33. implicit def asScalaBufferConverter[A](l: java.util.List[A]): AsScala[Buffer[A]]

    Adds an asScala method that implicitly converts a Java List to a Scala mutable Buffer.

    Adds an asScala method that implicitly converts a Java List to a Scala mutable Buffer.

    See also

    asScalaBuffer

  34. implicit def asScalaIteratorConverter[A](i: java.util.Iterator[A]): AsScala[Iterator[A]]

    Adds an asScala method that implicitly converts a Java Iterator to a Scala Iterator.

    Adds an asScala method that implicitly converts a Java Iterator to a Scala Iterator.

    See also

    asScalaIterator

  35. implicit def asScalaSetConverter[A](s: java.util.Set[A]): AsScala[mutable.Set[A]]

    Adds an asScala method that implicitly converts a Java Set to a Scala mutable Set.

    Adds an asScala method that implicitly converts a Java Set to a Scala mutable Set.

    See also

    asScalaSet

  36. implicit def bufferAsJavaListConverter[A](b: Buffer[A]): AsJava[java.util.List[A]]

    Adds an asJava method that implicitly converts a Scala mutable Buffer to a Java List.

    Adds an asJava method that implicitly converts a Scala mutable Buffer to a Java List.

    See also

    bufferAsJavaList

  37. def clone(): AnyRef

    Create a copy of the receiver object.

    Create a copy of the receiver object.

    The default implementation of the clone method is platform dependent.

    returns

    a copy of the receiver object.

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
    Note

    not specified by SLS as a member of AnyRef

  38. implicit def collectionAsScalaIterableConverter[A](i: Collection[A]): AsScala[Iterable[A]]

    Adds an asScala method that implicitly converts a Java Collection to an Scala Iterable.

    Adds an asScala method that implicitly converts a Java Collection to an Scala Iterable.

    See also

    collectionAsScalaIterable

  39. implicit def dictionaryAsScalaMapConverter[K, V](p: Dictionary[K, V]): AsScala[mutable.Map[K, V]]

    Adds an asScala method that implicitly converts a Java Dictionary to a Scala mutable Map.

    Adds an asScala method that implicitly converts a Java Dictionary to a Scala mutable Map.

    See also

    dictionaryAsScalaMap

  40. implicit def enumerationAsScalaIteratorConverter[A](i: java.util.Enumeration[A]): AsScala[Iterator[A]]

    Adds an asScala method that implicitly converts a Java Enumeration to a Scala Iterator.

    Adds an asScala method that implicitly converts a Java Enumeration to a Scala Iterator.

    See also

    enumerationAsScalaIterator

  41. final def eq(arg0: AnyRef): Boolean

    Tests whether the argument (that) is a reference to the receiver object (this).

    Tests whether the argument (that) is a reference to the receiver object (this).

    The eq method implements an equivalence relation on non-null instances of AnyRef, and has three additional properties:

    • It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false.
    • For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false.
    • null.eq(null) returns true.

    When overriding the equals or hashCode methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).

    returns

    true if the argument is a reference to the receiver object; false otherwise.

    Definition Classes
    AnyRef
  42. def equals(arg0: AnyRef): Boolean

    The equality method for reference types.

    The equality method for reference types. Default implementation delegates to eq.

    See also equals in scala.Any.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    Definition Classes
    AnyRef → Any
  43. def finalize(): Unit

    Called by the garbage collector on the receiver object when there are no more references to the object.

    Called by the garbage collector on the receiver object when there are no more references to the object.

    The details of when and if the finalize method is invoked, as well as the interaction between finalize and non-local returns and exceptions, are all platform dependent.

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
    Note

    not specified by SLS as a member of AnyRef

  44. final def getClass(): Class[_ <: AnyRef]

    Returns the runtime class representation of the object.

    Returns the runtime class representation of the object.

    returns

    a class object corresponding to the runtime type of the receiver.

    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  45. def hashCode(): Int

    The hashCode method for reference types.

    The hashCode method for reference types. See hashCode in scala.Any.

    returns

    the hash code value for this object.

    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  46. final def isInstanceOf[T0]: Boolean

    Test whether the dynamic type of the receiver object has the same erasure as T0.

    Test whether the dynamic type of the receiver object has the same erasure as T0.

    Depending on what T0 is, the test is done in one of the below ways:

    • T0 is a non-parameterized class type, e.g. BigDecimal: this method returns true if the value of the receiver object is a BigDecimal or a subtype of BigDecimal.
    • T0 is a parameterized class type, e.g. List[Int]: this method returns true if the value of the receiver object is some List[X] for any X. For example, List(1, 2, 3).isInstanceOf[List[String]] will return true.
    • T0 is some singleton type x.type or literal x: this method returns this.eq(x). For example, x.isInstanceOf[1] is equivalent to x.eq(1)
    • T0 is an intersection X with Y or X & Y: this method is equivalent to x.isInstanceOf[X] && x.isInstanceOf[Y]
    • T0 is a union X | Y: this method is equivalent to x.isInstanceOf[X] || x.isInstanceOf[Y]
    • T0 is a type parameter or an abstract type member: this method is equivalent to isInstanceOf[U] where U is T0's upper bound, Any if T0 is unbounded. For example, x.isInstanceOf[A] where A is an unbounded type parameter will return true for any value of x.

    This is exactly equivalent to the type pattern _: T0

    returns

    true if the receiver object is an instance of erasure of type T0; false otherwise.

    Definition Classes
    Any
    Note

    due to the unexpectedness of List(1, 2, 3).isInstanceOf[List[String]] returning true and x.isInstanceOf[A] where A is a type parameter or abstract member returning true, these forms issue a warning.

  47. implicit def iterableAsScalaIterableConverter[A](i: java.lang.Iterable[A]): AsScala[Iterable[A]]

    Adds an asScala method that implicitly converts a Java Iterable to a Scala Iterable.

    Adds an asScala method that implicitly converts a Java Iterable to a Scala Iterable.

    See also

    iterableAsScalaIterable

  48. implicit def mapAsJavaConcurrentMapConverter[K, V](m: concurrent.Map[K, V]): AsJava[ConcurrentMap[K, V]]

    Adds an asJava method that implicitly converts a Scala mutable concurrent.Map to a Java ConcurrentMap.

    Adds an asJava method that implicitly converts a Scala mutable concurrent.Map to a Java ConcurrentMap.

    See also

    mapAsJavaConcurrentMap.

  49. implicit def mapAsJavaMapConverter[K, V](m: Map[K, V]): AsJava[java.util.Map[K, V]]

    Adds an asJava method that implicitly converts a Scala Map to a Java Map.

    Adds an asJava method that implicitly converts a Scala Map to a Java Map.

    See also

    mapAsJavaMap

  50. implicit def mapAsScalaConcurrentMapConverter[K, V](m: ConcurrentMap[K, V]): AsScala[concurrent.Map[K, V]]

    Adds an asScala method that implicitly converts a Java ConcurrentMap to a Scala mutable concurrent.Map.

    Adds an asScala method that implicitly converts a Java ConcurrentMap to a Scala mutable concurrent.Map.

    See also

    mapAsScalaConcurrentMap

  51. implicit def mapAsScalaMapConverter[K, V](m: java.util.Map[K, V]): AsScala[mutable.Map[K, V]]

    Adds an asScala method that implicitly converts a Java Map to a Scala mutable Map.

    Adds an asScala method that implicitly converts a Java Map to a Scala mutable Map.

    See also

    mapAsScalaMap

  52. implicit def mutableMapAsJavaMapConverter[K, V](m: mutable.Map[K, V]): AsJava[java.util.Map[K, V]]

    Adds an asJava method that implicitly converts a Scala mutable Map to a Java Map.

    Adds an asJava method that implicitly converts a Scala mutable Map to a Java Map.

    See also

    mutableMapAsJavaMap

  53. implicit def mutableSeqAsJavaListConverter[A](b: mutable.Seq[A]): AsJava[java.util.List[A]]

    Adds an asJava method that implicitly converts a Scala mutable Seq to a Java List.

    Adds an asJava method that implicitly converts a Scala mutable Seq to a Java List.

    See also

    mutableSeqAsJavaList

  54. implicit def mutableSetAsJavaSetConverter[A](s: mutable.Set[A]): AsJava[java.util.Set[A]]

    Adds an asJava method that implicitly converts a Scala mutable Set to a Java Set.

    Adds an asJava method that implicitly converts a Scala mutable Set to a Java Set.

    See also

    mutableSetAsJavaSet

  55. final def ne(arg0: AnyRef): Boolean

    Equivalent to !(this eq that).

    Equivalent to !(this eq that).

    returns

    true if the argument is not a reference to the receiver object; false otherwise.

    Definition Classes
    AnyRef
  56. final def notify(): Unit

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Definition Classes
    AnyRef
    Annotations
    @native()
    Note

    not specified by SLS as a member of AnyRef

  57. final def notifyAll(): Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

    Wakes up all threads that are waiting on the receiver object's monitor.

    Definition Classes
    AnyRef
    Annotations
    @native()
    Note

    not specified by SLS as a member of AnyRef

  58. implicit def propertiesAsScalaMapConverter(p: Properties): AsScala[mutable.Map[String, String]]

    Adds an asScala method that implicitly converts a Java Properties to a Scala mutable Map[String, String].

    Adds an asScala method that implicitly converts a Java Properties to a Scala mutable Map[String, String].

    See also

    propertiesAsScalaMap

  59. implicit def seqAsJavaListConverter[A](b: Seq[A]): AsJava[java.util.List[A]]

    Adds an asJava method that implicitly converts a Scala Seq to a Java List.

    Adds an asJava method that implicitly converts a Scala Seq to a Java List.

    See also

    seqAsJavaList

  60. implicit def setAsJavaSetConverter[A](s: Set[A]): AsJava[java.util.Set[A]]

    Adds an asJava method that implicitly converts a Scala Set to a Java Set.

    Adds an asJava method that implicitly converts a Scala Set to a Java Set.

    See also

    setAsJavaSet

  61. final def synchronized[T0](arg0: => T0): T0

    Executes the code in body with an exclusive lock on this.

    Executes the code in body with an exclusive lock on this.

    returns

    the result of body

    Definition Classes
    AnyRef
  62. def toString(): String

    Creates a String representation of this object.

    Creates a String representation of this object. The default representation is platform dependent. On the java platform it is the concatenation of the class name, "@", and the object's hashcode in hexadecimal.

    returns

    a String representation of the object.

    Definition Classes
    AnyRef → Any
  63. final def wait(): Unit

    See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--.

    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
    Note

    not specified by SLS as a member of AnyRef

  64. final def wait(arg0: Long, arg1: Int): Unit

    See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-

    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
    Note

    not specified by SLS as a member of AnyRef

  65. final def wait(arg0: Long): Unit

    See https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-.

    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
    Note

    not specified by SLS as a member of AnyRef

Deprecated Value Members

  1. def asJavaIterable[A](i: Iterable[A]): java.lang.Iterable[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asJava instead

  2. def asJavaIterator[A](i: Iterator[A]): java.util.Iterator[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asJava instead

  3. def asScalaBuffer[A](l: java.util.List[A]): Buffer[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asScala instead

  4. def asScalaIterator[A](i: java.util.Iterator[A]): Iterator[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asScala instead

  5. def asScalaSet[A](s: java.util.Set[A]): mutable.Set[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asScala instead

  6. def bufferAsJavaList[A](b: Buffer[A]): java.util.List[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asJava instead

  7. def collectionAsScalaIterable[A](i: Collection[A]): Iterable[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asScala instead

  8. def dictionaryAsScalaMap[A, B](p: Dictionary[A, B]): mutable.Map[A, B]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asScala instead

  9. def enumerationAsScalaIterator[A](i: java.util.Enumeration[A]): Iterator[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asScala instead

  10. def iterableAsScalaIterable[A](i: java.lang.Iterable[A]): Iterable[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asScala instead

  11. def mapAsJavaConcurrentMap[K, V](m: concurrent.Map[K, V]): ConcurrentMap[K, V]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asJava instead

  12. def mapAsJavaMap[K, V](m: Map[K, V]): java.util.Map[K, V]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asJava instead

  13. def mapAsScalaConcurrentMap[A, B](m: ConcurrentMap[A, B]): concurrent.Map[A, B]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asScala instead

  14. def mapAsScalaMap[A, B](m: java.util.Map[A, B]): mutable.Map[A, B]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asScala instead

  15. def mutableMapAsJavaMap[K, V](m: mutable.Map[K, V]): java.util.Map[K, V]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asJava instead

  16. def mutableSeqAsJavaList[A](s: mutable.Seq[A]): java.util.List[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asJava instead

  17. def mutableSetAsJavaSet[A](s: mutable.Set[A]): java.util.Set[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asJava instead

  18. def propertiesAsScalaMap(p: Properties): mutable.Map[String, String]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asScala instead

  19. def seqAsJavaList[A](s: Seq[A]): java.util.List[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asJava instead

  20. def setAsJavaSet[A](s: Set[A]): java.util.Set[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use asJava instead

Inherited from AsScalaConverters

Inherited from AsJavaConverters

Inherited from AnyRef

Inherited from Any

Ungrouped