Java Basics Flashcards
What is it important to note with brackets?
For ever open bracket ( { [ …
There is a close bracket ) } ]
Write the skeleton/framework
import arc.*;
public class -name-{
public static void main(String [] args){
Console con = new Console();
} }
Location of Import Commands
top of the program
Function of Import Command
to import different programming libraries
What do Libraries give?
access to specific Java commands
to import different programming libraries
Function of Import Command
Write the import command for the arc library.
import arc.*;
Function of this command:
import arc.*:
imports the arc library
Function of this command:
public class javabasics2{
}
title of the java program
note: the title needs to match the saved file title exactly
Notes about the title:
no spaces
cannot start with a number
no special characters
What file extension name should you save your programs under?
.java
Function of this command:
public static void main(String[] args){
}
represents the main method of the java program
What do all Java programs have?
a public static void main
Function of this command:
Console con = new Console();
provides Console window
Function of Console window
number and text input
text or graphics output
Function of RAM Command
Tells RAM to reserves space for future data
Tells RAM to reserves space for future data
Function of RAM Command
number and text input
text or graphics output
Function of Console Window
Write the code which provides a console window.
Console con = new Console ();
Write the command which provides the main method of the program.
public static void main(String [] args){
}
Data type that holds integer data
int
int
data type that holds integer data
Function of GPU/Monitor Output Command
tells computer to print whatever is in quotes to the screen + data in variables
Write an example of GPU/Monitor Command
con.println(“example”);
or
con.print(“example”);
or
con.println(“example” + intVariable);
con.println (); vs con.print(“something”);
println – cursor goes to next line
print – cursor stays on same line
Function of Keyboard Input Command
tells computer to read integer/double/string data from the keyboard AND put data into the variable
Write an example of Keyboard Input Command
intVariable = con.readInt();
or
dblVariable = con.readDouble();
or
strVariable = con.readLine();
Where is the data of variables stored?
in RAM
Function of CPU Math Command
- tells CPU to perform calculations on the r.h.s. of the ‘=’
- puts results into variable on l.h.s. of the equal sign
Function of %
Modulus sign - does integer division but takes remainder
Data type that holds real number data
double
double
Data type that holds real number data
Symbol for Comments
//
Purpose for Writing Comments
- organize code
- explain complex thought processes
- communitcate with team member reading your code
- understand what a part of code does when revisiting it
Unit of measurement of angles in trigonometry calculations in Java
radians
String
data type which holds words, letters, punctuation, and numbers
note: cannot do math with numbers
Write an example of setting variables as string data
String strVariable;
Write an example of setting variables as integer data
int intVariable;
Write an example of setting variables as double data
double dblVariable;
Math.min
compares two numbers and gets smallest
Math.max
compares two numbers and gets the biggest
Math.round
rounds to nearest decimal point
Math.toRadians
converts degree –> radians