The difference between Scala and Java

Source: Internet
Author: User

1, Scala and Java have 7 numeric types: int, short, long, byte, float, double, Boolean 7 kinds, but in Scala, these 7 types of values are classes, in Java, the basic type, Java, Data types are divided into basic types and reference types, which are not differentiated in Scala.
2. The type of a variable or function in Scala is always written behind a variable or function name
3. The operators in Scala are no different from the operators in Java, but in Scala, the operator is a method, in Java the operator is not a method, and in Scala a special character other than the alphanumeric can be used as a method
4. The wildcard character in Scala is the wildcard character in _,java is *
5. The unit in Scala is equivalent to void in Java
6, Scala's if/else expressions are similar to those in Java, but there are values in Scala
7, Scala is not static, but you can use object to achieve the same effect in Java, Scala object can implement a single case
8. Scala supports association mappings, such as using (key-> value) to represent a key value pair
9, Scala contains two types of variables, Val variable equivalent to Const,var in Java is a general variable
10. Scala has type inference, and can omit the type description, such as: Val x = 4, in cases where context inference is possible.
11, Scala through the DEF keyword definition function, in the case of the default explicit return statement, returns the last computed value of the function
12, Scala uses println direct output to the standard output, without System.out.println
13. The array index in Scala is args (0), not args[0 in Java]
14. Scala contains the new container object tuple, which can contain several different types of objects
15. Scala does not have the "+ +" operator
16, Scala advocates functional programming style, reduce the use of var variables, so you can get more concise and more readable code

Https://my.oschina.net/jhone/blog/309466?p=1
http://blog.csdn.net/u012441545/article/details/51882491

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.