This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RuntimeJavaErrorDemo { | |
public static void main(String[] args) { | |
String test = null; | |
System.out.println(test.length()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test { | |
var x = None | |
println(x.length) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
var age = -1 | |
var name = "Unnamed" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorial(a:Int): Int = { | |
if(a <=1) 1 else a * factorial(a-1) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let factorial 0 = 1; factorial n = n * factorial (n - 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorial(a: Int) = { | |
if (a <= 1) 1 else a * factorial(a - 1) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val x = 20 | |
//print to the console | |
//legit, gets inferred as an integer | |
println(x+10) | |
//Something stupid as below will throw compile time error | |
val z = 40 | |
println(z * "justastring") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val t = 69 | |
//Prints 'E' the ASCII value of E is 69 | |
println(t.toChar) | |
val s = "Hello World" | |
//Just like String char at, prints l | |
//Trace leads to the same String class charAt method | |
println(s.charAt(2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final ArrayList<Integer> arrList = new ArrayList<Integer>(); | |
//This does not result in error, we are mutating the object itself | |
//If it were mutable it would result in error to something like it cannot be changed | |
arrList.add(20); | |
//This results in error as we are modifying the reference and not the object itself | |
arrList = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorld { | |
def main(args : Array[String]){ | |
println("Hello world") | |
} | |
} |