1import org.junit.Assert;
2import org.junit.Test;
3
4public class Test {
5
6 public static int square(int n) {
7 return n * n;
8 }
9
10 @Test
11 public void squareTest() {
12 Assert.assertEquals(25, square(5));
13 Assert.assertEquals(16, square(4));
14 Assert.assertEquals(9, square(3));
15 Assert.assertEquals(4, square(2));
16 Assert.assertEquals(1, square(1));
17 }
18}
19
1 An incredible language that receives far more hate than it deserves
2because of it's poor beginnings.
3 Everyone remembers the slow java applets but often fail to understand
4Java's many positives including:
5 - compatability with many different systems
6 - Just-In-Time compilation making it almost as fast as a native language
7 - the wide range of high-quality and open source libraries developed over
8 many years
9
10 Sure, it may not look as sexy as Python or NodeJS, but when you're
11debugging the call stack 50 functions deep, you'll be glad you picked Java
1import org.junit.Assert;
2import org.junit.Test;
3
4public class Test {
5
6 public static int square(int n) {
7 return n * n;
8 }
9
10 @Test
11 public void squareTest() {
12 Assert.assertEquals(25, square(5));
13 Assert.assertEquals(16, square(4));
14 Assert.assertEquals(9, square(3));
15 Assert.assertEquals(4, square(2));
16 Assert.assertEquals(1, square(1));
17 }
18}