Java Grade 11
Java Grade 11
“INTRO TO JAVA”
Characteristics of Java
Java is Simple
Java is Secure
Java is Robust
Java is Case-Sensitive
Components of Java
Java Virtual Machine (JVM) – refers to the virtual machine that serves as the base for the Java platform
Java Application Program Interface (API) – refers to the collection of readymade software components
Syntax
- Basic of the language, all the main rules, commands, construction to write programs
- Rules for combining words into statements
Grammar
Classes
Statements
Identifiers
Variables
Literals
Types of Literals
Primitive Operators
Data Types
Types of Variables
Increment or Decrement – operator that provides a more convenient way to increase or decrease value
Prefix – Increments the variable’s values and uses the new value in the expression
Postfix – the variable’s value is first used in the expression and is then increased
Strings
String Concatenation – forms a new String that is the combination of multiple strings
Java Comments
- are the statements in a program that are not executed by the compiler but the interpreter
Single Line Comment – starts with two forward slashes
Multi-Line Comment – used to comment multiple lines of codes
Documentation Comment – just like multi-line but they generate external documentation of your code
- Decide which task-based statement, block, or code is executed based on a given criteria
- Structured Statements that allows to change the way statements in a program is executed
Decision Control Structure – allow control over specific sections of code
Repetition Control Structure – allow repeated execution of specific sections of code
If Statement Structure
Logical Statements
“And” Operator
“Or” Operator
Default Statements – can be used for performing a task when none of the case is matched
While Loops Structure – basic repetition control structure that repeats statements as a conditional statement
For Loops Structure – provides a compact way to iterate over a range of values used in loops
Do-While Loops Structure – evaluates the statement’s condition at the end of the structure instead of the beginning
Branching Statements – statements that specifically dictate the flow of control within a program
Break Statement – causes the termination of a loop or initiates an exit from a decision control structure
Continue Statement – forces the next iteration of a loop to take place using a set of condition
- A data structure that can be used in Java that is composed of a sequence of memory locations for storing data
- Composed of elements that contains values of a common data type, such as integers, characters, and strings
- Any collection of items
Arrays
Declaring Arrays
Instantiating Arrays
Multidimensional Arrays
System.out.print() – used to print strings in a single line without line breaks for each consecutive statement
System.out.println() – used to print strings with a line break at the end
Printing