- Scala Tutorial
- Scala - Home
- Scala - Overview
- Scala - Environment Setup
- Scala - Basic Syntax
- Scala - Data Types
- Scala - Variables
- Scala - Classes & Objects
- Scala - Access Modifiers
- Scala - Operators
- Scala - IF ELSE
- Scala - Loop Statements
- Scala - Functions
- Scala - Closures
- Scala - Strings
- Scala - Arrays
- Scala - Collections
- Scala - Traits
- Scala - Pattern Matching
- Scala - Regular Expressions
- Scala - Exception Handling
- Scala - Extractors
- Scala - Files I/O
- Scala Useful Resources
- Scala - Quick Guide
- Scala - Useful Resources
- Scala - Discussion
Scala - 关系运算符
尝试以下示例程序来了解 Scala 编程语言中可用的所有关系运算符。
例子
object Demo { def main(args: Array[String]) { var a = 10; var b = 20; println("a == b = " + (a == b) ); println("a != b = " + (a != b) ); println("a > b = " + (a > b) ); println("a < b = " + (a < b) ); println("b >= a = " + (b >= a) ); println("b <= a = " + (b <= a) ); } }
将上述程序保存在Demo.scala中。以下命令用于编译和执行该程序。
命令
\>scalac Demo.scala \>scala Demo
输出
a == b = false a != b = true a > b = false a < b = true b >= a = true b <= a = false
scala_operators.htm