From charlesreid1

Revision as of 10:01, 4 September 2016 by Admin (talk | contribs) (→‎File I/O)

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!


String Manipulation