帮忙!

landyshouguo 2008-04-22 11:40:34
import java.util.*;
import java.text.*;
public class Abc
{
public static void main()
{
long DAY = 24L * 60L * 60L * 1000L;
SimpleDateFormat df = new SimpleDateFormat( "MM.dd.yyyy" );
Date d1 = df.parse( "04.30.2001" )throws ParseException;
Date d2 = df.parse( "05.01.2001" )throws ParseException;
System.out.println( "The number days between:" );
System.out.println( d1 );
System.out.println( "and:" );
System.out.println( d2 );
System.out.println( "is: " + (( d2.getTime() - d1.getTime() ) / DAY ));
}
}



运行不了,帮助!
...全文
72 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
wensheng_zh2007 2008-04-23
  • 打赏
  • 举报
回复
书看的少了,或者说是没有仔细看
Dragon_sxw 2008-04-23
  • 打赏
  • 举报
回复
呵呵, 错误不少,看书。。。
guoxiaopeng1982 2008-04-23
  • 打赏
  • 举报
回复
……………………楼主好好看书,这么基础的问题哦……错误不是这样抛出的
thunderclap 2008-04-23
  • 打赏
  • 举报
回复
throws是在定义方法的时候,跟在方法后面,表示该方法有可能抛出异常.
然后我们在自己写的方法里面,如果调用有throws的方法的时候,需要try{}catch(){}处理,或继续向上抛出异常
  • 打赏
  • 举报
回复
依据五楼的改吧。。
多看点书运行学习。。。
panxuan 2008-04-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yiyi_wx 的回复:]
public static void main(String[] args)
[/Quote]
cnjzy0106 2008-04-23
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 M_song 的回复:]
1,main方法有错;
2,异常捕获有问题;
import java.util.*;
import java.text.*;
public class Abc
{
public static void main(String args[]) throws Exception
{
long DAY = 24L * 60L * 60L * 1000L;
SimpleDateFormat df = new SimpleDateFormat( "MM.dd.yyyy" );
Date d1 = df.parse( "04.30.2001" );
Date d2 = df.parse( "05.01.2001" );
System.ou…
[/Quote]
duzhonghua 2008-04-23
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 M_song 的回复:]
1,main方法有错;
2,异常捕获有问题;
import java.util.*;
import java.text.*;
public class Abc
{
public static void main(String args[]) throws Exception
{
long DAY = 24L * 60L * 60L * 1000L;
SimpleDateFormat df = new SimpleDateFormat( "MM.dd.yyyy" );
Date d1 = df.parse( "04.30.2001" );
Date d2 = df.parse( "05.01.2001" );
System.ou…
[/Quote]
M_song 2008-04-23
  • 打赏
  • 举报
回复
1,main方法有错;
2,异常捕获有问题;
import java.util.*;
import java.text.*;
public class Abc
{
public static void main(String args[]) throws Exception
{
long DAY = 24L * 60L * 60L * 1000L;
SimpleDateFormat df = new SimpleDateFormat( "MM.dd.yyyy" );
Date d1 = df.parse( "04.30.2001" );
Date d2 = df.parse( "05.01.2001" );
System.out.println( "The number days between:" );
System.out.println( d1 );
System.out.println( "and:" );
System.out.println( d2 );
System.out.println( "is: " + (( d2.getTime() - d1.getTime() ) / DAY ));
}
}
jiazhengjing 2008-04-22
  • 打赏
  • 举报
回复
异常不是这么捕获的。
要放在try{}catch{}里面。
yiyi_wx 2008-04-22
  • 打赏
  • 举报
回复
public static void main(String[] args)

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧