cd: change directory. example cd C:\helloworld.dir: list the content in the directory.
/**
* The HelloWorldApp class implements an application that
* simply displays "Hello World!" to the standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); //Display the string.
}
}
|
HelloWorldApp.javajavac HelloWorldApp.javajava HelloWorldAppmain: entry point of the program (like the main function in C++)System.out.println : similar to cout in C++. Always end with a new line
class HelloWorldApp2 {
public static void main(String[] args) {
System.out.println("Hello " + args[0]);
}
}
|
HelloWorldApp2.javajavac HelloWorldApp2.javajava HelloWorldApp2 Charles (or java HelloWorldApp2 Amy)Hello Charles (or Hello Amy)args is an array of Stringargs[0] is the first argument(i.e Charles or Amy)+ to add 2 Strings together. .java files are compiled into .class files. .class files are the Java bytecode..class files) are interpreted by Java Virtual Machine.