Praktisi Mengajar 2022: Java Primitive & Non-Primitive Data Types
Praktisi Mengajar 2022: Java Primitive & Non-Primitive Data Types
Go to VScode =>
<VARIABLES/>
2x + 2 = 12
Berapa nilai x?
x + y = 5
x - y = 1
Berapa nilai x dan y?
<VARIABLES/>
Go to VScode =>
<STRINGS/>
Strings are used for storing text. A String variable contains a
collection of characters surrounded by double quotes:
teks.length()
teks.toUpperCase()
teks.toLowerCase()
teks.indexOf( "e")
<ARRAYS/>
BALLS FRUITS
<ARRAYS/>
Go to VScode =>
<METHODS/>
<METHODS/>
Kalikan(4, 20);
Kalikan(6, 7);
Kalikan(10, 9);
<RETURN METHODS/>
The void keyword, used in the examples before, indicates that
the method should not return a value. If you want the method
to return a value, you can use a primitive data type (such as
int, char, etc.) instead of void, and use the return keyword
inside the method.
Go to VScode =>
<CONTROL FLOW STATEMENTS/>
if (condition) {
// block of code to be executed
// if the condition is true
}
<IF-ELSE STATEMENT/>
Use the else statement to specify a block of code to be
executed if the condition is false.
if (condition) {
// run if the condition is true
} else {
// run if the condition is
false
}
<SWITCH STATEMENT/>
switch(expression) {
The switch expression is evaluated
case x:
once. The value of the expression is
// code block
compared with the values of each
break;
case y: case. If there is a match, the
// code block associated block of code is executed.
break; break keyword will breaks out of the
default: switch block. The default keyword
// code block specifies some code to run if there
} is no case match
<END/>