In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article focuses on "how to install and use Scala". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install and use Scala.
1, hands-on experience of Scala on the command line and Scala IDE for Eclipse
Scala is a static language based on JVM's combination of object-oriented and functional programming. Installing and running Scala first requires a Java virtual environment. Download and install Java directly from the official website:
Http://www.oracle.com/technetwork/java/javase/downloads/index.html
Since the latest 1.0.2 version of Spark supports Scala 2.10.X, while Scala 2.10.X does not support Java 8, you need to download Java 6 or Java 7 when downloading (you need to pay attention to the system version. Jialin's system is the 64-bit version of Window 7). After installation and configuration, you need to verify it at the command line:
Next, install Scala 2.10.4 at the download address:
Http://www.scala-lang.org/download/2.10.4.html
After downloading, click install. After installation, you need to configure the bin directory of scala to the environment variable path, and verify it with the command line after installation and configuration:
Enter the Scala command line:
To define a constant in Scala is to use val:
If you modify the value of the relative name at this time, an error will be reported:
Declare a variable using var:
Modify the variable hobby at this time:
We can find that we do not define the type of constant and variable when we define it, but the command terminal shows the type and its type, which is the self-push ability of Scala type. Scala can push to the type of variable and constant itself according to the type of variable and constant value.
Of course, you can display the specified type:
Next, download Scala IDE for Eclipse, see how to write Scala code in Eclipse, and download the version of Scala2.10.4 at the following address:
Http://scala-ide.org/download/sdk.html
After download, you can decompress and start it directly.
Create a Scala project:
Create a scala package under src:
Next, create a Scala class named "HelloScala":
Next, to write our main function, we need to note that in Scala, the main function needs to exist in the object object, so we need an object HelloScala and write the main method in it:
After writing, select "Run as" as "Scala Application". The running result is as follows:
Next, use def to define a function "hello":
There are two points to note in Scala:
1. The value of the last line of the function body is the return value of the entire function.
2. The declaration of the type is after the variable or function or class
Print out the execution result of the function:
To carry out the revised procedure:
Let's look at the definition, use, and execution of another method:
At this point, I believe you have a deeper understanding of "how to install and use Scala". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.