Operators Precedence in Scala Last Updated : 12 Jul, 2025 Suggest changes Share 1 Likes Like Report An operator is a symbol that represents an operation to be performed with one or more operand. Operators are the foundation of any programming language. Which operator is performed first in an expression with more than one operators with different precedence is determined by operator precedence. For example, 10 + 20 * 30 is calculated as 10 + (20 * 30) and not as (10 + 20) * 30. when two operators of the same precedence appear in expression associativity is used. Associativity can be Right to Left or Left to Right. For example ‘*’ and ‘/’ have the same precedence and their associativity is Left to Right, so the expression “100 / 10 * 10” is worked as “(100 / 10) * 10”. In below table operators with the highest precedence appear at the top of the table and operators with the lowest precedence appear at the bottom. Operator Category Associativity ()[] Postfix Left to Right ! ~ Unary Right to Left * / % Multiplicative Left to Right + - Additive Left to Right >> >>> << Shift Left to Right < <= > >= Relational Left to Right == != Relational is equal to/is not equal to Left to Right == != Equality Left to Right & Bitwise AND Left to Right ^ Bitwise exclusive OR Left to Right | Bitwise inclusive OR Left to Right && Logical AND Left to Right | | Logical OR Left to Right = += -= *= /= %= >>= <<= &= ^= |= Assignment Right to left , Comma (separate expressions) Left to Right Below is the example of operator Precedence. Example : Scala // Scala program to show Operators Precedence // Creating object object gfg { // Main method def main(args: Array[String]) { var a:Int = 20; var b:Int = 10; var c:Int = 15; var d:Int = 5; var e = 0 // operators with the highest precedence // will operate first e = a + b * c / d; /* step 1: 20 + (10 * 15) /5 step 2: 20 + (150 /5) step 3:(20 + 30)*/ println("Value of a + b * c / d is : " + e ) } } Output: Value of a + b * c / d is : 50 In above example e = a + b * c / d; here, e is assigned 50, not 120 because operator * has a higher precedence than / than +, so it first gets multiplied with 10 * 15, then divide by 5 and then add into 20. Create Quiz D DivyaPareek Follow 1 Article Tags : Scala Scala-Operator Explore OverviewScala Programming Language3 min readIntroduction to Scala7 min readSetting up the environment in Scala3 min readHello World in Scala2 min readBasicsScala Keywords2 min readScala Identifiers3 min readData Types in Scala3 min readVariables in Scala3 min readControl StatementsScala | Decision Making (if, if-else, Nested if-else, if-else if)5 min readScala | Loops(while, do..while, for, nested loops)5 min readBreak statement in Scala3 min readScala | Literals4 min readOOP ConceptsClass and Object in Scala5 min readInheritance in Scala5 min readOperators in Scala11 min readScala Singleton and Companion Objects3 min readScala Constructors4 min readScala | Polymorphism5 min readScala | Multithreading3 min readScala this keyword2 min readMethodsScala | Functions - Basics3 min readAnonymous Functions in Scala2 min readScala | Closures3 min readRecursion in Scala4 min readMethod Overloading in Scala5 min readMethod Overriding in Scala8 min readLambda Expression in Scala4 min readScala Varargs2 min readStringsScala String4 min readScala | String Interpolation3 min readScala | StringContext2 min readRegular Expressions in Scala5 min readStringBuilder in Scala4 min readScala PackagesPackages In Scala4 min readScala | Package Objects3 min readChained Package Clauses in Scala3 min readFile Handling in Scala3 min readScala TraitScala | Traits7 min readScala | Sealed Trait4 min readScala | Trait Mixins3 min readTrait Linearization in Scala5 min readCollectionsScala Lists5 min readScala ListBuffer6 min readListSet in Scala6 min readScala Map5 min readScala | Arrays6 min readScala | ArrayBuffer4 min readScala | Tuple5 min readSet in Scala | Set-13 min readSet in Scala | Set-27 min readBitSet in Scala5 min readHashSet In Scala4 min readStack in Scala3 min readHashMap in Scala3 min readTreeSet in Scala4 min readIterators in Scala5 min readScala | Option3 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like