Courses‎ > ‎AP Computer Science‎ > ‎Konstantinovich‎ > ‎notes‎ > ‎

2017-09-12

posted Sep 12, 2017, 10:15 AM by Samuel Konstantinovich
Emacs25 

Windows:
  https://www.emacswiki.org/emacs/MsWindowsInstallation
Mac:
  https://emacsformacosx.com/builds
Linux:
  You can do it!


Recap on Languages:
  • Compiled Language
    • Human readable source code is translated (compiled) into machine language. (binary)
    • Machine language contains instructions that are run directly by the computer.
  • Source code and machine code are different files.
  • Java is a hybrid of compiled and interpreted language
  • Java programs compile into java byte code, that does not run directly on a computer, they go through the java virtual machine (JVM)
    • The JVM is like an interpreter. It translates from byte code to machine instructions.
  • Source files have a .java extension and are human readable. They _must_ end in .java 
  • Source files are compiled into java byte code by the compiler (javac) and are stored in files which have .class extension.
  • .class files are readable by the JVM
  • All .class files are cross-platform (can be run on any OS that has a JVM)
  • Each platform has a specific JVM. Mac, Windows, Linux, etc.
Java Types:

-Java is statically-typed (variables must be declared before they can be used)

The primitive data types: (you need the ones underlined)
byte/short/int/long
float/double
boolean
char

int (32 bit, values from -2^31 to +2^31-1)
double(64 bit)
boolean (size not defined)
char (16 bits , 0 to 65,535)

Other Data Types:
A String is not a primitive type. Strings are special because they are objects, and we will learn about them more later.

Note: Semicolons are used to separate statements and are placed at the end of most statements. Exceptions will be discussed.

Variables : They store values, and you can change them by re-assigning after they are assigned. You cannot use a variable before it is assigned. 

declaration:
<type> <name>;
e.g.
int x;
float z;

assignment:
<name> = <expression>;
x = 3;
z = 2*3.14159+1;

declare + assign:
<type> <name> = <expression>;
char c = 'f';
String s = "whoa!";

Reassignment - can have the original variable in the expression:
x = x + 1; 
fish = fish + cat; //assumes fish and cat have values and are compatible with addition.

New Stuff:

declare + assign multiples:
int x,y;
double a = 3.0, b = 5.123;

Literal - a fixed value written in the source code. Not a variable or expression.
e.g.
54
"hello"
1.3
true
1.23e2 (doubles can be written in engineering notation!)

Identifier - the name given to a variable/function.
May not start with a digit, and may contain letters, digits, _ , and $ . (Don't use dollar signs, and don't use underscores except when discussed in class)
e.g.
a
b
x
fish
num$dollars (terrible name)
x123
GRAVITY_OF_MOON
hi_there


Terminal Stuff

Commands you should know and love:
cp     mv     mkdir    rmdir
ls       cd      pwd      rm
cat    man

Commands you should learn to love:
emacs    ssh    less    more  grep

Cool Commands that won't be required:
|   :  (pipe)  lets you run the output of one program into another program
wc  : word count     
sort  :  sorts things...




More detailed Linux/Unix tutorial:



Comments