Training Guide ‐ Java Syntax - vinhtbkit/bkit-kb GitHub Wiki

Java is a popular programming language, created in 1995.

Target: the trainee will know how to write a simple Java function and knowledge about Types, Variables, and Operators in Java.
Expected Duration: maximum 24 hours of training and working on exercises.

Qualification criteria:

  • The trainees have knowledge of Java types, variables, conditional and loop operators
  • The trainees know how to create and use a Java function.
    • Specify the signature of a function
  • Know how to compile and run a Java file in the command line.

Intro to Java:

  • Basics about Java
  • Java versions

Setup Java environment

  • Know how to install Java
    • OPTIONAL using sdkman
    • Understanding JAVA_HOME
    • Difference between JDK and JRE
    • Using multiple versions of Java on same machine
  • Write a Hello World program using vi/vim/ or Visual Studio Code
  • Compile and run

References

Java Syntax

Naming Conventions

  • Learn the naming conventions in Java

References:

Quizzes:

  • How to compile a Java file?
  • How to run a Java bytecode file?
  • Different between a .class file and .java file?
  • What is the responsibility of the public static void main(String[] args) function?
  • How many primitive types does Java have? List them.
  • What is the special of String type?

Assignments:

Requires:

Java 11 or higher, Using the command line to compile and run a Java file.

Exercise:

  1. Write a small program to calculate the sum of array integer numbers inputted from the command line. Ex: input: 1,2,3,4,5 -> you need to split the string by , to get an array integer number.
java Sum 1,2,3,4,5
> 15
  1. Write a small program to count words (not numbers) from a string inputted from the command line.
java CountWords "Hello World"
> 11

*Note: The user input will be obtained from the args parameter of the public static void main(String[] args).