Java: Difference between revisions
From charlesreid1
No edit summary |
|||
| Line 39: | Line 39: | ||
Hello, world! | Hello, world! | ||
</pre> | </pre> | ||
=String Manipulation= | =String Manipulation= | ||
Revision as of 10:01, 4 September 2016
Cool: http://www.ibm.com/developerworks/library/j-robots/index.html
Getting Started
Download and install Java, if you need to.
Hello World
This will walk through compiling and running a "Hello world" example in Java.
The program
Here's a simple Java "Hello world" program:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
Compiling
To compile this program, use the javac command:
$ javac HelloWorld.java
This will create a HelloWorld.class file, which is the Java executable.
Running
To run a Java executable, use the java command, and pass it the executable's filename without the extension:
$ java HelloWorld Hello, world!