These are just notes I’ve made for myself while going thought the book “Head First Java”
Today’s Notes:
Source file Contains one Class, Class Contains one or more Methods, One method contains a set of statements.
Basic “Hello World” Program:
class HelloWorldApp {
public static void main (String[] args) {
System.out.println(“Hello World!”);
}
}
NOTE the “S” in String[] is capitalized. Along with System, but I had gotten that one right. (Book uses a different example)
Must have a “main” method in every app, but not in every class. Apps can contain multiple Class files.
Syntax:
- Statements end in Semicolon’s
- Most white spaces don’t matter
- Must declare type and name of variables (ie. int weight;)
- Classes and methods must be defined with in curly braces { }
- // Single Line Comments
- /* Multiline comments
are like this with the Asterisk slashes */
while (condition) {
statement;
}
for (initialization; termination; increment) {
Statement;
}
One thing I can’t seem to remember the order of creation.
- write / Save the .java file
- Comple .java file : javac appfile.java This makes the .class file
- Run the .class file: java appfile.
Comments
Leave a comment Trackback