Loading the lesson...
In the print dialog, choose "Save as PDF" as the destination.
Foundations: goals, tools, and the Java environment
Eclipse is the recommended IDE (any preferred IDE works)Write
.java source file
Compile
javac turns source into bytecode
Run
the JVM executes the bytecode
javac compiles source into bytecode, saved as a .class file, executed by the JVMJRE + compilers + tools (JavaDoc, debugger, etc.) - needed to create, compile, and run Java programsJDK (JVM + browser plugin/applet support); enough to run a compiled program, but not to compile oneString - a sequence of characters, like a Python string| Type | Meaning |
|---|---|
int | integers, roughly ±2^31 |
long | larger integers, roughly ±2^63 |
boolean | true or false |
double | floating-point numbers |
char | single characters, e.g. A and $ |
a and b are int, the compiler knows a + b is also intEclipse checks this as you type, catching many errors before you even run the programMath.sine(2), wrong argument count/types, wrong return type)Watch Out
5/2 truncates to an integer, it does not return a fractionint and long are finite ranges; a computation that overflows quietly wraps around to the wrong answer instead of erroringdouble has NaN, POSITIVE_INFINITY, NEGATIVE_INFINITY instead of raising a dynamic error (e.g. divide by zero, sqrt of a negative number)final int num;final.java source, compile with javac to bytecode, run on the JVM (platform independent)JDK = JRE + development tools; JRE alone can only run compiled programsNaN/Infinity); prefer immutability where possibleMahmoud Abas|Software Construction Week 1