Home »
Code Examples »
Scala Code Examples
Scala - Declaring Scala Supported Types Using Inference Code Example
The code for Declaring Scala Supported Types Using Inference
println("Declaring Scala Supported Types Using Inference")
val age = 21
val bigNumber = 123456789L
val weight1 = 65.50
val weight2 = 65.50f
val name = "Alvin Alexander"
val aByte = 0xaf
val aLetter = 'R'
val nothing = ()
// Printing
println("Values and Types...")
println("age: " + age + " (" + age.getClass + ")")
println("bigNumber: " + bigNumber + " (" + bigNumber.getClass + ")")
println("weight1: " + weight1 + " (" + weight1.getClass + ")")
println("weight2: " + weight2 + " (" + weight2.getClass + ")")
println("name: " + name + " (" + name.getClass + ")")
println("aByte: " + aByte + " (" + aByte.getClass + ")")
println("aLetter: " + aLetter + " (" + aLetter.getClass + ")")
println("nothing: " + nothing + " (" + nothing.getClass + ")")
/*
Output:
Declaring Scala Supported Types Using Inference
Values and Types...
age: 21 (int)
bigNumber: 123456789 (long)
weight1: 65.5 (double)
weight2: 65.5 (float)
name: Alvin Alexander (class java.lang.String)
aByte: 175 (int)
aLetter: R (char)
nothing: () (void)
*/
Code by IncludeHelp,
on August 8, 2022 03:51