Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.*;
import java.util.Date;

public class Main {

    public static void main(String[] args) {
        Object obj1 = "Object";
        Object obj2 = 2;
        Date date = new Date();
        try {

            PrintWriter pw = new PrintWriter(System.out);

            // print object
            pw.println(obj1);

            // print another object
            pw.println(obj2);

            // print a date (it is an object)
            pw.print(date);

            // flush the writer
            pw.flush();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}