package javaapi
- Alphabetic
- Public
- All
Value Members
- 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 converted. Changes to the original collection are reflected in the view, and vice versa.
The following conversions are supported via
asScala
andasJava
: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.
- 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.
- 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.
- object FutureConverters
This object contains methods that convert between Scala Future and Java CompletionStage.
This object contains methods that convert between Scala Future and Java 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 Future (instead of scala.concurrent.Promise) and 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
andPromise
) are completed independently at the same time, they may contain different values afterwards. For this reason,toCompletableFuture
is not supported on the createdCompletionStage
s. - object OptionConverters
This object contains methods that convert between Scala
Option
and JavaOptional
types.This object contains methods that convert between Scala
Option
and JavaOptional
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.
- 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.
This is the documentation for the Scala standard library.
Package structure
The scala package contains core types like
Int
,Float
,Array
orOption
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 frameworkscala.collection.immutable
- Immutable, sequential data-structures such asVector
,List
,Range
,HashMap
orHashSet
scala.collection.mutable
- Mutable, sequential data-structures such asArrayBuffer
,StringBuilder
,HashMap
orHashSet
scala.collection.concurrent
- Mutable, concurrent data-structures such asTrieMap
scala.concurrent
- Primitives for concurrent programming such asFutures
andPromises
scala.io
- Input and output operationsscala.math
- Basic math functions and additional numeric types likeBigInt
andBigDecimal
scala.sys
- Interaction with other processes and the operating systemscala.util.matching
- Regular expressionsOther 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 forscala.collection.immutable.List
.Other aliases refer to classes provided by the underlying platform. For example, on the JVM,
String
is an alias forjava.lang.String
.