Intro To Java
Intro To Java
to Java
Codeffine
What is Java?
Java
It
This
Binary
Computers
It is platform-independent.
This means the programs you write can be ran on any platforms.
Windows, OSX, Linux, etc.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads2133151.html
This allows you to develop and run Java programs!
http://www.filehippo.com/download_netbeans/
If you have install third-party themes or patch windows system files, please
restore them using sfc/scannow in cmd because custom files has been known
to cause issues.
Note: You could program without an IDE, but its much harder.
Open Netbeans.
What is a class?
What is a method?
What is a variable?
What is syntax?
Example
In
Syntax time!
System.out.println(HelloWorld);
In Java, curly braces must be used to indicate the start and end
of a class or method.
For example.
//statements
^ means there cant be two or more variables with the same name in
the same method. But it will be ok for both methodA and methodB to
have variables with same name. This is because the variable is in
different scope.
This is not really a syntax rule. This means it will not create an
error even if you choose to not follow this rule.
Camel Case: the first letter of the word is lowercase. All the
following first letter of words will be uppercase.
Example
String numOfPrograms
int numOfKids
String lionelMessi
System.out.println(HelloWorld);
} //end of class
Scope of
Method
Scope of
class
Exploring System.out.println();
System.out.println(HelloWorld);
You write what you want to print in the brackets (). If you are not
going to print out variables you will need like the above
example.
Summary
The data that can be stored is based on the data type you used.
a, b, c
Reference: String
Variables
They are used in conjunction with data types to specify what type
of data to hold.
Naming variables
No space
No special character
Use camelCase. Not using this will not create an error but its
java style.
Using variables
Declaring
char y;
boolean trueOrFalse;
double xy;
String letters;
Using variables
Initializing (Refer to slide above for what type of data the variable
was initialized into)
x = 2;
xy = 4.0; note that even if we just input 4, the Java will turn it into
4.0
trueOrFalse = true;
String: null
int: 0
double: 0.0
Boolean: false