---
# System prepended metadata

title: 'Java Notes:'

---

# Java Notes:

> - **Objected Oriented Programming.**
> - **Write once, run Anywhere.**

## 1 - **How does Java Work?**:

Java was developed in order to make it possible for every operating system/device to understand a single type of code (instructions) with the use of JVM (Java Virtual Machines) that will allow every device to understand what the program wants to do without needing specific instructions for every type of operating system.

Java code -> Compiler -> Bytecode -> JVM -> Machinecode

## 2 - **Coding & Compiling**:

Java is a **compiled-language**, meaning that your coded **.java** file will be checked for *errors* and possible issues (*warnings*) when compiling the code. If you have errors in your code, you will be forced to fix them before the code will compile into an executable **.class** file.


## 3 - **Variables**: 
### Primitives:
> **Primitive data types**: Simplest types of data with no built-in behavior.
> **Object data types**: Objects have built-in behavior.

- **Boolean**s
    - Can store either "true" or "false". 
- **Integer**s
    - Can store a flat number between -2147483648 and 2147483648 (can't store decimal spots)
- **Double**s
    - Can store numbers with decimal points.
- **Char**s
    - Can store a single character ('A' for example)

### Strings

- **String Literal:**
    - Any sequence of characters enclosed in double-quotes (""). Like primitive-type variables, we declare a String variable by specifying the type first.
- **String Object:**
    - Calling the String class when declaring a String.

**String Escapes:**
- The **\\"** escape sequence allows us to add quotation marks (") to a String value.
- The **\\\\** escape sequence allows us to place backslashes in our String.
- The **\n** escape sequence in a String will make the compiler output a new line of text instead of contuining in the same line.