- Java can be used to build:
- Web applications
- Mobile applications
- Desktop applications
- Web servers
- Embedded systems
- use for building and developing Java applications
- Includes the JRE and other tools to create Java programs
- use for running Java applications
- has Libraries and classes
- JVM Java Virtual Machine
- execute Java programs
- 1st: need to complied Java source code to Java byte code
javac Filename.java
- 2nd: to run the code
java FileName
- Anytime you change the source code you need to complied the code before you run the code.
- is a software we can use to build and run Java programs
- Built for compiling and executing code
- has a Graphical User Interface (GUI)
- Contains built-in tools to make the development process faster
- Example:
- Output using
System.out.println()
to the console - Input using
Scanner input = new Scanner(System.in)
this allow the user to input information to the console;- Scanner is a class in java.util package used for obtaining the input of the primitive types like int, double, etc. and strings.
- A program's control flow is the order in which the program's instructions or code statements are executed.
- Relational Operators
- less than
<
- greater than
>
- equal to
==
- greater than or equal to
>=
- less than or equal to
<=
- not equal to
!=
- less than
- An if statement is a control flow statement, where if the condition is true, it performs some kind of action
- The scope of a variable is the part of the program where a piece of code is accessible or in which it can be used
- Curly braces
{}
create different blocks or regions in Java
- A while loop allows code to be executed repeatedly based on a Boolean condition
- involves locating and fixing a program's errors (bugs)
- use print statements to print the value of a given variable and follow the control flow of a code
- are misspelled variable or missing semicolon
- can cause your code to fail before it runs
- the code must be in the right format for a computer to read
- deal with the logic of a program
- the program doesn't act as the user expects
- helps compile and run Java programs
- helps debug Java programs by detecting and revealing errors
- Breakpoints: an intentional stopping point put into a program for debugging purposes. This allow us to inspect its internal state
- click the line of code number and run the code in debug mode
- internal state: variable values, the result of certain lines of code is executed ot not
- Breakpoints: an intentional stopping point put into a program for debugging purposes. This allow us to inspect its internal state
- organizing and group your classes together
- single line uses
//
in the begin - multi line uses
/*can add multi comments between */
- is a box that store data types
- Boolean: represent a true or false value (Ex: Is a light on or off)
- Int: represent a whole number (Ex: number of siblings)
- Double: represent a decimal number (Ex: your GPA 3.3)
- Char: represent a single letter or symbol (Ex: your First initial)
- String: a sequence of ordered characters (Ex: a word or person's name) or built out of characters
- String value: will have quotation marks around it (
"speaker"
) - String variable:
string myFavoriteWord = "speaker"
- String operation:
- charAt: is a special string operation that allows us to access a character at a specific location within the string
variable.charAt(index)
- Input: index of the wanted character
- Output: the value of the character at the inputted index
- charAt: is a special string operation that allows us to access a character at a specific location within the string
- String value: will have quotation marks around it (