Tt
Click this widget to change the font size.
CC
Click this widget to change contrast.

Home Page 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Links | Search | Bio | Faculty

Guide to HTML, CSS, and JavaScript (University at Buffalo Version)


Chapter 2: Creating Your First Web Page

Java is a popular programming language that is especially suited to develop applications for business and the Internet of Things (IoT).

This guide will use the Eclipse IDE (Neon version) to develop the java code.

Hello World!

Most beginning programmers start with the standard "Hello World" code:

package buffalo.edu.fa20.assignments.put-your-lastname-here;

/**
 *
 * File: helloworld.java
 *
 * This is a Hello World Application
 * It prints a short statement to the standard out
 */

public class HelloWorld {
/**
 * The main methid is the entry point for a Java program when executed
 *
 * @param args String[] - command line arguments passed to program
 * @return none
 */

  public static void main(String[] args) {
  // print to the console
    System.out.println("Hello World!");
  }
}

Figure 2-1: Code for helloworld.java

The Eclipse Console would look like this:

Console
<terminated>
Hello World!

Figure 2-2: HelloWorld.java Console Output

Java Comments

Java provides inline, single line, multi-line, and JavaDoc comments. You can even use HTML tags in JavaDoc comments.

JavaDoc comments:
    
  /**
  * The <b>main</b> method is the entry point for a Java program when executed
  *
  * @param args String[] - command line arguments passed to program
  * @return none
  */
  
Multi-line comments:

/*
 This
 is
 a
 multi-line
 comment
*/

Single line comments:

// print to the console

Inline comments:

  System.out.println("Hello World!");// print this out
   
Figure 2-3: Java Comment Examples