Scala Standard Library2.13.18 < Back


# Packages

-  package root

  This is the documentation for the Scala standard library.

  This is the documentation for the Scala standard library.

  #### Package structure

  The scala package contains core types like `Int`, `Float`, `Array` or `Option` which are accessible in all Scala compilation units without explicit qualification or imports.

  Notable packages include:

  - `scala.collection` and its sub-packages contain Scala's collections framework
    - `scala.collection.immutable` - Immutable, sequential data-structures such as `Vector`, `List`, `Range`, `HashMap` or `HashSet`
    - `scala.collection.mutable` - Mutable, sequential data-structures such as `ArrayBuffer`, `StringBuilder`, `HashMap` or `HashSet`
    - `scala.collection.concurrent` - Mutable, concurrent data-structures such as `TrieMap`
  - `scala.concurrent` - Primitives for concurrent programming such as `Futures` and `Promises`
  - `scala.io` - Input and output operations
  - `scala.math` - Basic math functions and additional numeric types like `BigInt` and `BigDecimal`
  - `scala.sys` - Interaction with other processes and the operating system
  - `scala.util.matching` - Regular expressions

  Other packages exist. See the complete list on the right.

  Additional parts of the standard library are shipped as separate libraries. These include:

  - `scala.reflect` - Scala's reflection API (scala-reflect.jar)
  - `scala.xml` - XML parsing, manipulation, and serialization (scala-xml.jar)
  - `scala.collection.parallel` - Parallel collections (scala-parallel-collections.jar)
  - `scala.util.parsing` - Parser combinators (scala-parser-combinators.jar)
  - `scala.swing` - A convenient wrapper around Java's GUI framework called Swing (scala-swing.jar)

  #### Automatic imports

  Identifiers in the scala package and the `scala.Predef` object are always in scope by default.

  Some of these identifiers are type aliases provided as shortcuts to commonly used classes. For example, `List` is an alias for `scala.collection.immutable.List`.

  Other aliases refer to classes provided by the underlying platform. For example, on the JVM, `String` is an alias for `java.lang.String`.

  Definition Classes
    root
-  package scala

  Core Scala types.

  Core Scala types. They are always available without an explicit import.

  Definition Classes
    root
-  package jdk

  The jdk package contains utilities to interact with JDK classes.

  The jdk package contains utilities to interact with JDK classes.

  This packages offers a number of converters, that are able to wrap or copy types from the scala library to equivalent types in the JDK class library and vice versa:

  - CollectionConverters, converting collections like scala.collection.Seq, scala.collection.Map, scala.collection.Set, scala.collection.mutable.Buffer, scala.collection.Iterator and scala.collection.Iterable to their JDK counterparts
  - OptionConverters, converting between Option and java.util.Optional and primitive variations
  - StreamConverters, to create JDK Streams from scala collections
  - DurationConverters, for conversions between scala scala.concurrent.duration.FiniteDuration and java.time.Duration
  - FunctionConverters, from scala Functions to java java.util.function.Function, java.util.function.UnaryOperator, java.util.function.Consumer and java.util.function.Predicate, as well as primitive variations and Bi-variations.

  By convention, converters that wrap an object to provide a different interface to the same underlying data structure use .asScala and .asJava extension methods, whereas converters that copy the underlying data structure use .toScala and .toJava.

  In the javaapi package, the same converters can be found with a java-friendly interface that don't rely on implicit enrichments.

  Additionally, this package offers Accumulators, capable of efficiently traversing JDK Streams.

  Definition Classes
    scala
-  package javaapi
  Definition Classes
    jdk
- CollectionConverters
- DurationConverters
- FunctionConverters
- FutureConverters
- OptionConverters
- StreamConverters

p

scala.jdk

# javaapi

#### package javaapi


Ordering

1. Alphabetic

Visibility

1. Public
2. Protected

### Value Members

1.  object CollectionConverters extends AsJavaConverters with AsScalaConverters

   This object contains methods that convert between Scala and Java collections.

   This object contains methods that convert between Scala and Java collections.

   The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.CollectionConverters.

   Note: to create Java Streams that operate on Scala collections (sequentially or in parallel), use StreamConverters.

       // Java Code
       import scala.jdk.javaapi.CollectionConverters;
       public class A {
         public void t(scala.collection.immutable.List<String> l) {
           java.util.List<String> jl = CollectionConverters.asJava(l);
         }
       }

   The conversions return adapters for the corresponding API, i.e., the collections are wrapped, not copied. Changes to the original collection are reflected in the view, and vice versa.

   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 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.

2.  object DurationConverters

   This object contains methods that convert between Scala and Java duration types.

   This object contains methods that convert between Scala and Java duration types.

   The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.DurationConverters.

3.  object FunctionConverters

   This object contains methods that convert between Scala and Java function types.

   This object contains methods that convert between Scala and Java function types.

   The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.FunctionConverters.

   For details how the function converters work, see scala.jdk.FunctionConverters.

4.  object FutureConverters

   This object contains methods that convert between Scala scala.concurrent.Future and Java java.util.concurrent.CompletionStage.

   This object contains methods that convert between Scala scala.concurrent.Future and Java java.util.concurrent.CompletionStage.

   The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.FutureConverters.

   Note that the bridge is implemented at the read-only side of asynchronous handles, namely scala.concurrent.Future (instead of scala.concurrent.Promise) and java.util.concurrent.CompletionStage (instead of java.util.concurrent.CompletableFuture). This is intentional, as the semantics of bridging the write-handles would be prone to race conditions; if both ends (`CompletableFuture` and `Promise`) are completed independently at the same time, they may contain different values afterwards. For this reason, `toCompletableFuture` is not supported on the created `CompletionStage`s.

5.  object OptionConverters

   This object contains methods that convert between Scala `Option` and Java `Optional` types.

   This object contains methods that convert between Scala `Option` and Java `Optional` types.

   The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.OptionConverters.

6.  object StreamConverters

   This object contains methods to create Java Streams that operate on Scala collections (sequentially or in parallel).

   This object contains methods to create Java Streams that operate on Scala collections (sequentially or in parallel). For more information on Java streams, consult the documentation (https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html).

   The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.StreamConverters.

   Note: to convert between Scala collections and classic Java collections, use CollectionConverters.

   For details how the stream converters work, see scala.jdk.StreamConverters.

### Ungrouped