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
usingsdkman
- Understanding
JAVA_HOME
- Difference between JDK and JRE
- Using multiple versions of Java on same machine
- Write a
Hello World
program usingvi/vim/
orVisual Studio Code
- Compile and run
References
Java Syntax
- Understanding basic Java syntax
- Variables
- Data types
- Primitive: boolean, char, int, short, byte, long, float, and double
- Non primitive: String, Array, Class, Object, Interface...
- Operators:
- Assignment, Arithmetic, and Unary Operators
- Equality, Relational, and Conditional Operators
- Understand the
==
operator andequals
method:
Naming Conventions
- Learn the naming conventions in Java
References:
- Basic syntax
- Variables
- Data types
- https://www.geeksforgeeks.org/data-types-in-java/?ref=lbp
- https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
- https://www.w3schools.com/java/java_type_casting.asp
- https://www.geeksforgeeks.org/primitive-data-type-vs-object-data-type-in-java-with-examples/?ref=lbp
- String in Java: https://www.geeksforgeeks.org/strings-in-java/
- https://www.geeksforgeeks.org/wrapper-classes-java/?ref=lbp
- Operators
- Flows and expressions
- Naming convetions
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:
- 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
- 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)
.