日期:2014-05-20  浏览次数:20758 次

帮忙!
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 )); 
  }
}



运行不了,帮助!

------解决方案--------------------
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 ));



------解决方案--------------------
探讨
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…

------解决方案--------------------
探讨
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…

------解决方案--------------------
探讨
public static void main(String[] args)

------解决方案--------------------
依据五楼的改吧。。
多看点书运行学习。。。
------解决方案--------------------
throws是在定义方法的时候,跟在方法后面,表示该方法有可能抛出异常.
然后我们在自己写的方法里面,如果调用有throws的方法的时候,需要try{}catch(){}处理,或继续向上抛出异常
------解决方案--------------------
……………………楼主好好看书,这么基础的问题哦……错误不是这样抛出的