Absolute Value in Kotlin

Level 128 keystrokes

Prints the absolute value of -7.

Kotlin code

// kotlin.math.abs() returns the absolute value (the fully qualified name avoids an import)
// The absolute value of -7 is 7
1println(kotlin.math.abs(-7))

Output

7
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Kotlin code and how often they appear.

  • .× 2
  • (× 2
  • )× 2
  • -× 1

More Kotlin examples at level 1

← Kotlin typing practice