- Basic concepts in probability theory (Chap 1.1-1.5)
- Discrete and continuous random variables (Chap 2.1-2.3)
- Calculating probabilities using CDF and PDF (Chap 2.2-2.3)
- Expectation, variance and moments(Chap 2.4)
- The Markov inequality (Chap 2.4)
A distinction should be made between the following 3 data types in Java:
[2, 3, 4]
int
s representing the numbers [2, 3, 4]
List<Integer>
representing the numbers [2, 3, 4]
Array<Integer>
, which you may accidentally be using without realizing, but don't worry about this for nowJava doesn't have [2, 3, 4] as a built in construct.
You'll get a compiler error because it's not valid Java syntax to assign such a thing to a variable.
Ask ChatGPT how to create a primitive array of [2, 3, 4]
, the syntax is slightly different.
/** | |
There is a paradigm shift in assignment 1 and assignment 2 in terms of | |
"inversion of control": https://en.wikipedia.org/wiki/Inversion_of_control. | |
The "main" method of a Java program is the entrypoint to start the program. | |
In assignment 1, your main program was invoked. | |
In assignment 2, a main program, which you don't control, invokes your code stubs. | |
*/ | |
public class Assignment2 { | |
// Suppose the assignment told you to implement a method that matches this signature |
====== Compiling your code ====== | |
Compiling: ['UserInputTest.java']... | |
====== Running JUnit on your code ====== | |
[FAIL] Test int input with value 1000000 | |
-> Expected integer 1000000 to be printed as '1000000', but got: ''. ==> expected: <1000000> but was: <> | |
[FAIL] Test string input with Belgium replacement | |
-> Expected 'Brugge is in Belgium' to be replaced by 'Southern Netherlands' and truncated to 30 characters, but got: ''. ==> expected: <Brugge is in Southern Netherla> but was: <> | |
[FAIL] Test invalid input type | |
-> Expected error message 'Your type of input is not valid.' for invalid input type, but got: ''. ==> expected: <true> but was: <false> | |
[FAIL] Test the string input from first example |
/** | |
Reproduces "No line found" error | |
*/ | |
public class UserInput { | |
public static void main(String[] args) { | |
Scanner s = new Scanner(System.in); | |
s.nextLine(); | |
s.nextLine(); | |
s.nextLine(); | |
} |