2.5. Anatomy of a Simple Java Program
Let's write the simplest possible Java program to begin. When run, this program will output the text string “Hello,” along with the value of the name variable to the command line.
2.5.1. Hello.java
/* file: Hello.java purpose: print a simple string to the command line author: E Hewitt created date: 4.12.02 */ package javaforcf; // declare the name and visibility of this class public class Hello { // main method accepts an array of strings as arguments public static void main (String [] args) { // create a new String object with the value of 'Jeremy' String name = new String("Jeremy"); // print the static text and the variable together // out to the command line System.out.println("Hello," + name); } }
Get Java™ for ColdFusion® Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.