From charlesreid1

No edit summary
Line 39: Line 39:
Hello, world!
Hello, world!
</pre>
</pre>
=File I/O=
File I/O can be thought of in two parts: the file, and the contents of the file.
==The File==
A file can be represented using the '''File''' class. This is a handle to a file, and can be used to either obtain information about the file, or to pass to a file reader or writer to manipulate the file in some way.




=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!


String Manipulation