Variables Flashcards
What is the rules when declaring a variable?
****How to declare and use a variable****
- Variables must begin with a Alphabetical character
- Can only use numbers, alphabetical characters + _
- CANNOT BE A NAME THAT IS RESERVED WORD
What is the general structure of a java program?
What is the definition for variables
A symbol that holds a value that can be changed and maipulated
What is the int data type and how do you declare it?
int aInteger = 2121212121;
What is the double data type and how do you declare it?
double aDouble = 3.142;
What is the boolean data type?
boolean aBooleanValue = true;
What is the char data type?
char copyright = ‘\u00A9’;
What is the string data type
String aString = “Baby says that Joey is STOOPID “
How do you add two variables?
x += y;
x = x + y;
How do you subtract two variables
x -= y;
x = x - y;
How do you multiply two variables
x *= y;
x = x * y;
How do you divide two variables
x /= y;
x = x / y;
How do you mod two variables
x %= y;
x = x % y;
How do you perform a logical AND gate on two variables?
x &= y;
x = x & y;
How do you perform a logical OR gate on two variables
x |= y;
x = x| y;