Java Flashcards
what is the Java equivalent to DISPLAY?
System.out.println(…);
how do you display a String?
“___”
how do you compile a code?
javac (class name).java
how do you execute a code?
java (class name)
how do you make a comment?
// your comments here
what are the types of variables?
char String boolean int double
how do you write character types?
char x = ‘A’;
how do you write strings?
String “example”;
how do you write integers?
int exampleOne = 3;
how do you start a code?
public class (class name){ public static void main(String[] args){ // code here } }
what are the primitive data types?
char
boolean
int
double
what is camel-case?
start variable with a lowercase and then every new word starts with a capital letter
what are the compound assignment operators?
\+= (adds to variable) -= (subtracts from variable)
how do you turn an argument from a string into an integer or a double?
Integer.parseInt (args [0] )
Double.parseDouble [args [1] )
how do you write and, or, and not?
&&
||
!
what type is args[ ]?
String
how do you turn args [ ] into an integer or a double?
Integer.parseInt(args[ ]);
Double.parseDouble(args[ ]);
when do you NOT put a semicolon at the end of a line?
IFs and loops
what is a FOR loop and why is it used?
an alternative to a WHILE loop but it is more compact
how do you stop a never ending loop in the terminal?
Ctrl + C
what does BREAK do?
jumps out of the loop or it quits the loop
what does CONTINUE do?
skips the rest of the statements of the current loop iteration, continues with the next iteration