Please enable JavaScript.
Coggle requires JavaScript to display documents.
JAVA - Coggle Diagram
JAVA
BASIC
Arimethic Operation
Addition: +
Subtract: -
Multiply: *
Division: /
Modular: %
Arrays
Must same data type
int
int[ ] ... = {,,}
last index: arrayName.length-1
String
length = number of elements
Comparison Operation
Equal: ==
Not equal: !=
More than equal: >=
Less than equal: <=
More than: >
Less than: <
Function
Accept arguement/parameter
parameter in ()
Return a value
return varName
Return nothing
uses void
Method = function
If Else Statement
if (condition)
True: Run this block
if else (condition)
True: Run this block
else
None of above is True: Run this block
Input
Scanner name = new Scanner(System.in)
eg: if input = integer: int name = name scanner.nextInt()
eg: String input: String name = scanner name.next()
Logical Operator
boolean (true/false)
AND: &&
ALL conditions TRUE
return TRUE
OR: ||
One of condition TRUE
return TRUE
NOT: !
Statement TRUE = FALSE
&& >> ||
Print and Comment
// Single line
/
....
/ Multiple line
Variable and Data Type
Common
int: whole number
double: decimal
boolean: true/false
String: ".."
Others
byte
short
long
float
char
OBJECT ORIENTED PROGRAMMING
Encapsulation
Attribute in private
In order to access need to use
getter and setter
Inheritance
Sub class inherit parent class
Properties from parent can
be change/override by sub class
Abstraction
abstract parent class: method
declaration{No body}
subclass extends parent:
override
parent
method with {body}
Polymorphism
Many forms or shapes
OVERRIDING: same method but
different implementation with
parent
OVERLOADING: method with same name
in same class but doing different task
LOOPS
While Loop
Will iterate as long as
the statement is True
do while loop
Will print the statement first then check
the condition
Check the condition first then print
the statement
For Loop
We use when we know how many to iterate
for (statement1, statement2, statement 3)
Nested Loop
Loop inside a loop
Outside will runs first then finish
inside loop before proceed to 2nd
iteration of outside loop
Switch Statement
Used to check if any case
true with statement
If no True case then DEFAULT
will runs
After every case BREAK is used to stop once case is True
Access Modifier
Public
All can access even class from different package
Protected
Same as default but if want to use in different
package need to "extend"
Default
when we don't declare anything consider as default
only can be used in same package
Private
Only in class 1 can use the attributes
else need to declare "extend"
CLASS, OBJECT and CONDUCTOR
Object
Inside object has attribute and method
Class name + varName = new Class name()
Class
Main
Conductor
Conductor =many parameter
Object = one parameter
In form of public Class name(parameters)
Act as connecter between classes
GETTER and SETTER
Getter
To get the attribute
So must return a value/no void
getName()
Setter
To set/change the attribute
(setter = method)
We need to set the value
inside parathesis()
setName(Value)
STATIC and NON STATIC
Static
No need object to call static method/function
Non Static
Need to construct an object to call non static method/function