Ultimate Syntax CheatSheet for Kotlin, Python, Java and C++
Disclaimer: This is a work in progress. But it is being updated regularly.
This is a cheatsheet to make things easy for people who are coding in multiple languages in different projects at the same time, for whatever reasons.
1. Printing Stuff
Python
Java
Kotlin
C++
From this point on I’ll be skipping the formalities of these programming languages like importing iostream in C++ or declaring main function in Kotlin.
2. Taking Input (and variables)
Python
Java
Kotlin
val is different from var in Kotlin. The difference is that val is a constant variable and can’t be assigned multiple values, it is immutable. var is mutable and can be assigned multiple values.
As you might have noticed, Kotlin borrows the Scanner function from it’s parent programming language Java.
C++
3. Arrays and the For loop
Python
One dimensional Arrays are called lists in Python.
Java
Kotlin
C++
4. Multidimensional Arrays
Python
Java
We can take the input for the values of the array using Scaner. Or do something like this:
Kotlin
Here’s another way to declare and intialise multidimensional arrays in Kotlin: