Computer Science 15-100 (APEA Section E), Summer 2008
Class Notes: Introduction to Java
Logistics
- Second Day
- Syllabus + Course Policies
- Class mailing list
- Office Hours (DK: 12:30-1:30 in Wean 4614; GB: 6:00-7:00
in Wean 5419D).
- Reading:
- L&L Chapter 1 (Introduction)
- L&L Appendix B (Number Systems)
- L&L Appendix C (Unicode)
- Hw1: due tomorrow at start of class (no late hw accepted!)
- Quiz0 (practice): Tomorrow (treat this as a real quiz!)
- Quiz1 (real): Thursday
Topic Outline:
- Quick Q's
- What is log381? log2512? log2(1k)?
log2(1m)? log2(1b)? log2(2b)? log2(4b)?
- Roughly when will computers be 1m times faster than today?
- What is the Unicode value for 'A'? 'Z'? '0'? '9'?
' ' (space)?
- For any letter, what is the difference between its Unicode value for
lowercase versus uppercase?
- Installing Java, DrJava, JCreator
- Hello World
- Install software (Java + DrJava/JCreator/OtherIDE)
- Edit HelloWorld.java <--- Java source file
// HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
- Compile with "javac HelloWorld.java" to create HelloWorld.class
<-- Java bytecode file
- Interpret with "java HelloWorld" <-- The JVM (Java Virtual
Machine) interprets the bytecode
- Vocabulary:
- Sun, Java, Java SE,
Java ME, Java EE, Java 1.4, Java 1.5, Java 1.6, JRE, JVM, Browser,
Plug-in, Applet, Web Start, jar file, JDK
(or Java SDK), Compiler,
Interpreter, Editor, IDE, Libraries (Base Libraries, Swing, etc)
- Class
- Identifier
- Class names are UpperMixedCase
- Variable and Method names are lowerMixedCase
- Main method
- Comments
- End-of-line Comments // like this
- Block Comments /* like this */
- Good Comments (clear, concise, appropriate) and Bad Comments
(unclear, verbose, inappropriate -- too many / too few)
- String literal "like this"
- System.out.println method
-
Reserved Words (see p. 31)
- Identifiers Revisited:
Read The Purple Boxes!!!
- White space
-
Java
Code Conventions (Style Guide)
- Syntax versus Semantics
"Time flies like an arrow."
"The senator was trapped in one bad lie after another." (Is the
senator a liar or just a bad golfer?)
- Errors
- Compile-time error (Syntax error)
- Runtime error ("crash")
- Logical Error
- Problem Solving
- Define the problem
- Design the solution
- Implement the solution
- Test the solution
- Revise the problem or the design as needed (ie, go back to step 1 or
step 2)
- Time permitting: skim chapter 1 and/or time on hw1 (due
tomorrow!)
carpe diem -
carpe diem - carpe diem - carpe diem
- carpe diem - carpe diem -
carpe diem - carpe diem - carpe
diem