Variables Flashcards
Variables
Named locations in memory where we store information
Primitive Data Types
Types of Data built-in the Java system. The three main types are int, double, and Boolean
Literal
When the code is used to represent a fixed value
Ints
Store the whole number, with no fractions or decimals. Can be positive, negative, or zero
Double
Can store much higher numbers than int and can also store decimals and fractions
Booleans
Reference either true or false
Char
Holds any character, and surrounded by single quotation marks
String
Not a primitive type, holds a sequence of characters
How to create a string using a String literal
String greeting = “Hello World”;
How to create a string by calling the String class
String greeting = new String(“Hello World”);
Escape Sequences
Symbols with an alternative use in Java print Statements
Escape sequence for “”
"
Escape sequence for \
\\
Escape sequence for a new line
\n
What do variable names have to start with?
A letter, _, or $