Module 1 | Java Introduction, Static and main methods, Exceptions, Arrays, Dev Tools, Pre-post conditions¶
Objective¶
By the end of this module, students will be able to:
- Write simple Java programs involving objects, primitive types and arrays
- Understand the difference between static and non-static fields and methods
- Understand object references the consequence of the by value parameter passing
- Be able to program with exceptions
- Be able to document correctly Java programs
- Use the IntelliJ IDE
Resources¶
Slides (keynote)
- Lecture 1 Videos
- Lecture 1 Slides
- Youtube Live Q&A Session 2020-2021
- Restructuration Q&A Session 2021-2022
- Lecture 2 Videos
- Lecture 2 Slides
- Youtube Live Q&A Session
- W3schools Tutorial on Java
Exercises: week 1¶
- Intro to Java
- Exceptions
- Write code that generates exceptions
- CommonElements
- Convolution
- 1D and 2D arrays
Exercise 1.1.1¶
- Write a java program “Calculator” that takes a series of int argument from the command line, make the summation and prints the result. Hint parseInt method may be useful.
- Compile your program using javac (verify that the file
Calculator.class
has been generated) - Execute your program from the command line and verifies that it works:
java Calculator 10 2 13
should output 25 - Now edit your program in IntelliJ and pass the arguments from IntelliJ