Intro to Java; Info & Math in Java Flashcards
how does software work?
u boot the PC & it starts reading instruction from the storage device
the bytes r interpreted as instructions by the PC
the instructions = software –> created thru the process of programming
programming
giving sequential instructions to a computer system
done using a programming language
programming language
turned into instructions for a CPU by a compiler
series of rules that u follow to write English-like text representing abstract instructions
Ex: Java
compiler
a translator from the programming language instructions to the byte instructions used by the CPU
programming constructs
many programming languages have similar capabilites
Integrated Development Environment (IDE)
something like BlueJ that combines a text editor with a compiler
code
the text of a program
Java’s naming rules
starts with letter
can contain letters, #’s, $, and _
no spaces
case sensitive
sample print statement
public class CompSci {
public static void main (String [] args)
{
System.out.println("Hello World!");
}
}
whitespace
spaces, tabs, etc.
values & types
Java & all other programming languages have diff types of info
Ex: strings, integers, doubles, and Booleans
strings
look like text inside of a pair of quotation marks
integers
same thing as integers in math - whole #’s with no decimal point
doubles/floating-point values
what we might call real #’s in math - #’s that have a decimal point
Booleans
only 2 values: true and false
in Java, the words true and false (lowercase) r reserved for Boolean values
operators
the symbols that we use to perform calculations on diff values
arithmetic operators
+, -, *, /, %
paranthesis used same as in math
concatenation/catting
if u “add” anything to a string, it will stick the value onto the string
must be adding
Ex: “Hello” + “werld” = “Hellowerld”
50 + “8” = “508”
“Zoobah” + 0.5 * 3 = “Zoobah1.5”
integer division
when 2 integers r divided, the result is always an integer
Java will not round - will simply cut off
Ex: 6/4 = 1
2/3 = 0
if either of the values being divided is a double, then Java will do normal division
Ex: 1/5.0 = 0.2
Modulus Division
only works on integers
gives remainder of 1st # dvided by the 2nd #
Ex: 6%4 = 1R2 = 2
12%3 = 4R0 = 0
If the 1st # is less than the 2nd #, then the answer is always just the 1st #
Ex: 3%4 = 3