Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 5: Basic Types and Operationsย >ย 5.4 Arithmetic operations - Pg. 84

C HAPTER 5 ยท Basic Types and Operations Fast track for Java programmers Many aspects of Scala described in the remainder of this chapter are the same as in Java. If you're a Java guru in a rush, you can safely skip to Section 5.7 on page 88, which describes how Scala differs from Java in the area of object equality. 5.4 Arithmetic operations You can invoke arithmetic methods via infix operator notation for addition ( + ), subtraction ( - ), multiplication ( * ), division ( / ), and remainder (%), on any numeric type. Here are some examples: scala> 1.2 + 2.3 res6: Double = 3.5 scala> 3 - 1 res7: Int = 2 scala> 'b' - 'a' res8: Int = 1