Java Workshop Version Student
Java Workshop Version Student
WORKSHOP
Introduction to Java
02 When you run the Java program, Java compiler first compiles
your Java code to bytecode (with extension .class file). Then, the
JVM translates bytecode into native machine code (set of
instructions that a computer's CPU executes directly)
RUN JAVA PROGRAMS
Click This!
Run Button
Package Explorer
Console
Coding Area
START CODING USING ECLIPSE
Uncheck this
Click Finish
Right click src folder in Package Manager
Tick this
Click Finish
CODING AREA EXPLAIN
main will always
execute when
we click run
4. boolean 5. String
INT
What is an int?
Int (Integer) is a data type that
store whole number that include
negative, positive and 0 numbers.
Negative integers: -1, -46,
-67463
Positive integers: 5, 84, 77855
Zero: 0
EXAMPLE
JAVA INT DATA TYPE (ADVANCED)
-2147483648 to
int int myNum = 100000;
2147483647
-9223372036854775808 to
long long myNum = 15000000000L;
9223372036854775807
DOUBLE
What is a double?
Double is a data type that
store decimal numbers.
Negative double: -1.334,
-463.5, -0.3544
Positive double: 5.67,
0.345, 54323.67889
EXAMPLE
JAVA DOUBLE DATA TYPE (ADVANCED)
For Example:
BOOLEAN
What is a boolean?
Boolean (or commonly we write
as bool) is a data type that only
store 2 value, true or false.
EXAMPLE
TRY IT!
JAVA OPERATORS
WHAT IS OPERATOR?
Operator are used to perform operations on variables and values.
Example:
1723 % 5 = 3, because 15 % 7 = 1, because 34 % 2 = 0, because
INCREMENT AND DECREMENT
++number means number+1 !!!
== Equal to x == y
!= Not equal x != y
AND Case 02
Case 04
A && B, A is false and B is false, so A && B is
true or false?
Case 01
A || B, A is true and B is true, so A || B is
true or false?
OR Case 02
Case 04
A || B, A is false and B is false, so A || B
is true or false?
NOT Case 01
OPERATOR A is true, !A is true or false?
5. x= true, x && 1
6. x= 2, !(!(2+2) != !(2*2))
TRY IT!
JAVA INPUT
Java Input
To use the Java Input, first, you need to write
"import java.util.Scanner" at the top of the code,
then write "Scanner scanner = new
Scanner(System.in)" at the top of the main function
Java Input
After we declare scanner, we can use
scanner to get the user input. You can
decide the data type of the input.
Java Input
Type your answer in the console.