Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Scanner;

public class Main {
    public static void main(String[] ap) {
        int val;
        try {
            Scanner sc = new Scanner(System.in); // Requires J2SE 1.5
            val = sc.nextInt();
        } catch (NumberFormatException ex) {
            System.err.println("Not a valid number: " + ex);
            return;
        }
        System.out.println("I read this number: " + val);
    }
}