Java Netbeans IDE Function
Prepares the environment for developing java applications
IDE Full form
Integrated Development Environment
Java Netbeans
Platform to write Java code and applications (Version 7 ngayon)
What does java develop?
Desktop applications, client-server applications, mobile phone applications, games
Java major advantage
Platform independent
Java’s own runtime environment
Java Virtual Machine (JVM)
Current owner of java
Sun Microsystems
What to download?
Java Virtual Machine (JVM) and Java Development Kit (JDK)
Java code to write & extension
Source code wiith .java extension
What compiled the source code?
Another program called Javac that turns it into a Java byte code with .class extension (there should be no present errors)
File that Java Virtual Machine runs
Class file
Java Comments
Grayed out areas with forward slashes (// for single line comments; /* */ for multiline comments and asterisks that the compiler ignores
Javadoc comments
Starts with /** ends with */ to document the code (converted to HTML)
Java is case sensitive
True
Java code instructions end with a
Semicolon (;)
public class MyFirstProgram { }
Class segment notes the starting and ending of a java class segment code
Public static void main(String[] args){ }
Method
Public in “public static void main(String[] args){
the code can be accessed outside the class without creating new objects
Void in “public static void main(String[] args){
This part of the code does not return any value
Main in “public static void main(String[] args){
Denotes starting point of the java program
IntelliSense
NetBeans tries to display a list of available options after “.”
.Jar file (java archive) function
Cleans and builds your project with all necessary files for export if the program needs to be shared; will be put in a dist folder
Data
can be text, numbers, pointers, objects or some specified memory location
How is data accessed
Concatenation
Joining together direct text and a variable
You cannot start with a number for a variable name
True
You cannot have the same variable name with a keyword
True
Variable names can have a space
False
Variable names are not case sensitive
False
Java minimum and maximum value for numbers
+-2147483647 (use double to get a bigger/smaller number)
Operator Precedence
Order in which arithmetic’s operations are executed
Priority in operators
Multiplication & Division > addition and subtraction
Double quotes
String variable
Single quotes
char variable
Import java.util.Scanner; function
Tells java you want to use the scanner class in the util package of java library
Scanner in Import java.util.Scanner;
Class that handles inputs
Util in Import java.util.Scanner;
utility package of the java library where scanner is stored
Scanner variable
Scanner user_input = new Scanner (System.in);
New in Scanner user_input = new Scanner (System.in);
Creates the new objects
System.in in Scanner user_input = new Scanner (System.in);
Specifies for system input
User_input in Scanner user_input = new Scanner (System.in);
TThe variable that is called to call the input methods
Next method in Scanner user_input = new Scanner (System.in);
Gets the next string of text or int of number that a user types
Println
Cursor moves to a new line after the output
Cursor stays on the same line
If statement format
if(Condition {//codes to be executed if true}
Comparison Operators
Greater than, < Less than, >= greater or equal to, <= less than or equal to
Logical Operators
&& AND, || OR, == HAS A VALUE OF, ! NOT
If else statement structure
if(condition){code to be executed} else {code to be executed}
Nested IF statement
IF statement inside another IF statement
Boolean values
One with two choices: True or false, yes or no, 1 or 0
Switch statement definition
Selection statement; value of the expression is
compared with the values of each case; selecting one of many code blocks to be executed
Switch statement structure
switch(your test variable) { case Testing value: statement to be executed; break; default: statement to output if no matching case found; }
Looping/iteration
Repeat execution of statements a number of times; the same statement is being repeated many time over and at some point has to stop
For loop structure
for(initial value; condition; increment/decrement { statements to be repeated if true }
Intial value in for loops
Sets at what number should the repeat process start
Condition in for loops
Repeat should occur only when this condition is true
Increment/decrement
Move the counter forward or backward
Do while loop
do { Statements to execute } while (condition to check); // execution occur before checking of the condition
While loop
executes statements if the condition is true; while(condition) {}
Array definition
list store of values of the same type with specifying type eof data
Index starts at value…
0
Array structure
int[] myNums; [nextline ito] new int[5] to also indicate the size (all index are 0 unless stated)
Multidimensional arrays
arrays of multiple rows and columns (table) // 2 indices // int [][] myNums = new int[5][4]
.length
property of an array that returns the actual length of the array
Object-oriented programming
deals about creating objects that contain both data and functions
Oak
Java’s previous name
1995 by Oracle
Java created
Java requires:
main function that accepts an array of arguments enclosed in a class
Char description and size
nonprintable characters 16bits
Boolean description and size
True or false1 bit
Int description and size
whole numbers 32 bits
Short description and size
smaller than int 16 bits
Byte description and size
network packets 8 bits
Long description and size
larger than int 64 bits
Float description and size
numbers with floating points 32 bits
Double description and size
larger numbers with floating points
Format for declaring variables
Expression/statement function
changes the value of the variable being used in the condition
Continue in loops
the continue statement skips and moves to the end of the iteration
For-each traversal definition
for-each loop cycles through an object collection where type specifies array type and itvar is the iterator variable (accepts elements from beginning to end on eat a time)
For-each traversal format
for(type itvar:collection) statement block
Xvals in for(int xvals []:nums)
one-dimensional array of integers
Arraycopy
method available in the system class that can be used to copy data from one array to another