我正在写一个约会计划,我收到以下错误:
AppointmentNew.java:68: unreported exception java.text.ParseException; must be caught or declared to be thrown
Date lowDate = sdf.parse(stdin.nextLine());
^
AppointmentNew.java:70: unreported exception java.text.ParseException; must be caught or declared to be thrown
Date highDate = sdf.parse(stdin.nextLine());
^
AppointmentNew.java:77: unreported exception java.text.ParseException; must be caught or declared to be thrown
Date newCurrentDate = sdf.parse(currentDate);
Run Code Online (Sandbox Code Playgroud)
我很确定我需要尝试/捕捉,但我不知道如何制作它.我收到错误的部分是它要求用户输入BEGINNING和END日期,当他们这样做时程序然后打印出他们在两个日期之间做出的约会.
这是我的代码:
import java.util.*;
import java.text.SimpleDateFormat;
import java.util.Date;
public class AppointmentNew
{
public static void main (String[] args)
{
ArrayList<String> list = new ArrayList<String>();
Scanner stdin = new Scanner(System.in); …Run Code Online (Sandbox Code Playgroud) 我正在用Java编写一个约会程序,我遇到了一个错误,如下所示:
AppointmentNew.java:68: unreported exception java.text.ParseException; must be caught or declared to be thrown
Date lowDate = sdf.parse(stdin.nextLine());
^
AppointmentNew.java:70: unreported exception java.text.ParseException; must be caught or declared to be thrown
Date highDate = sdf.parse(stdin.nextLine());
^
AppointmentNew.java:77: unreported exception java.text.ParseException; must be caught or declared to be thrown
Date newCurrentDate = sdf.parse(currentDate);
Run Code Online (Sandbox Code Playgroud)
该程序假设允许用户进行新的约会,当他们这样做时,他们可以输入日期和描述(他们可以根据需要多次这样做),之后他们可以选择一系列日期程序打印输出(假设打印出他们提供的日期范围内的约会".这是我的错误发生的地方......
这是我的代码:
import java.util.*;
import java.text.SimpleDateFormat;
import java.util.Date;
public class AppointmentNew
{
public static void main (String[] args)
{
ArrayList<String> list = new ArrayList<String>();
Scanner stdin = new Scanner(System.in); …Run Code Online (Sandbox Code Playgroud)