Gr10 It Java Notes
Gr10 It Java Notes
What is Java?
Java is a popular programming language, created in 1995. It is used for:
Also
Java is a stand-alone application that can run on computers and laptops
Java programs are created in an IDE (Integrated Development Environment)
like NetBeans
Java files/programs are saved with a .jar extension
Main method
A Java program that can be run must have a main method, which is the
starting point of a program. The main method is enclosed in curly brackets. It
always has the heading:
Public static void main (String [] args)
Classes
Remember that every Java program has a class name which must match the
filename, and that every program must contain the main() method.
Term 2 Notes
Compile: This means converting your Java code into a form the computer can
understand (called bytecode). The compiler checks for errors too.
Run: This means actually executing the program so it does what you told it to
do — like showing a message or doing a calculation.
First you compile the code, then you run it.
The double forward slash and colon //: is used in Java mainly for
comments
// Sample comment
/* This is a
multi-line comment */
Curly brackets { } group code together, like the body of a class, method, or
loop. It is used to show the beginning and end of blocks of code. The actual
instructions to be carried out is within curly brackets
Indents: Make code easier to read by showing which code is inside a block
(like inside { }).
Blank lines: Add spacing to make the code more readable and organized.
They don’t change how the code works, but they help people understand it
better.
Statements
Statements are instructions telling the program what to do. All statements
end with a semi-colon;
OOP
Term 2 Notes
Java programs use objects which have properties. Code can be created to
determine the behaviour of an object by using its properties. This is called
Object-Orientated Programming (OOP)
Properties of an object are stored in fields. Fields are also called variables.
Tehe actions an object can carry out are called methods. Method names are
always followed with an open and close round bracket ()