Advance Computer Programming: by Hasnat Ali
Advance Computer Programming: by Hasnat Ali
By
Hasnat Ali
Contents
System.out.println("Welcome to Java!");
}
}
A Simple Java Program
import java.lang.*;
System.out.println("Welcome to Java!");
}
}
Trace a Program Execution
Execute statement
Compile
javac Welcome.java
Run
java Welcome
path and classpath
In short,
PATH = only for executable
CLASSPATH = for directories containing .class files,
JAR files & ZIP files.
path and classpath
PATH = C:\jdk1.7.0\bin
CLASSPATH = D:\Sample
Anatomy of a Java Program
Import package
Comments
Reserved words
Modifiers
Statements
Command-Line Arguments
Classes (constructor, data fields, Methods)
The main method
Importing package
javadoc Test.java
javadoc *.java
Documentation Comments – Running javadoc
Documentation Comments – Running javadoc
Running javadoc - Options
System.out.println("Welcome to Java!")
class Test{
public static void main(String args[]){
int x;
for(int i=0; i<args.length; i++){
x = Integer.parseInt(args[i]);
System.out.println(x);
}
}
}
For Each Loop
What is System.out.println?
It is a method: a collection of statements that performs a
sequence of operations to display a message on the
console. It can be used even without fully understanding
the details of how it works.