Scala - how to import Java classes? Code Example

The code for how to import Java classes?

// import one class
import java.io.File

// import every class in a package
import java.io._

// import multiple classes from a package (version 1)
import java.io.{File, IOException, FileNotFoundException}

// import multiple classes from a package (version 2)
import java.io.File
import java.io.FileNotFoundException
import java.io.IOException

// create an alias to a class you import
import java.io.{File => JFile}
Code by IncludeHelp, on August 13, 2022 21:58
Reference: alvinalexander.com

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.