I want to make a utility program which shows the date, hour ... :
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
public class hh {
public static void main(String[] args) {
Scanner mihai = new Scanner (System.in);
Date dNow = new Date( );
SimpleDateFormat ft = new SimpleDateFormat ("dd.MM.yyyy");
Date hNow = new Date( );
SimpleDateFormat ht = new SimpleDateFormat ("kk:mm");
String lol;
lol = mihai.nextLine();
switch (lol) {
case "Date":
lol = ft.format(dNow);
break;
case "Hour":
lol = ht.format(hNow);
break;
case "?":
lol = "2. Hour";
System.out.println("Supported functions:");
System.out.println("1. Date");
break;
default:
lol = "Type ? for help";
break;
}
}
}
But I use eclipse neon for editing the code, but after 1 use the program is terminated. I want to: When the program is at final auto restart it.(go to line 8).