Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dvt32/8190d981e15a622a71c99748969057d9 to your computer and use it in GitHub Desktop.
Save dvt32/8190d981e15a622a71c99748969057d9 to your computer and use it in GitHub Desktop.
// Conversion is not perfect, but can be helpful in the beginning
/*
public class MyJavaClass {
private int num = 5;
public void printNum() {
System.out.println(num);
switch (num) {
case 5: System.out.println("It's five!"); break;
case 6: System.out.println("It's six!"); break;
default: break;
}
for (int i = 0; i < 10; ++i) {
System.out.println(i);
}
for (int i = 10; i > 0; --i) {
System.out.println(i);
}
}
}
*/
class MyJavaClass {
private val num = 5
fun printNum() {
println(num)
when (num) {
5 -> println("It's five!")
6 -> println("It's six!")
else -> {}
}
for (i in 0..9) {
println(i)
}
for (i in 10 downTo 1) {
println(i)
}
}
}
// Kotlin to Java:
// - Tools > Kotlin > Show Kotlin Bytecode -> click on "Decompile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment