各位大哥,方法不行呀,还有一个,请大家看看:
例1:
import java.util.Calendar;
public class FirstApplication
{
//应用程序主方法
public static void main(String args[])
{
//变量声明
int hour, minute, second;
Calendar calendar = Calendar.getInstance();
//变量赋值
hour = calendar.get(Calendar.HOUR_OF_DAY);
//获得小时
minute = calendar.get(Calendar.MINUTE);
//获得分
second = calendar.get(Calendar.SECOND);
//获得秒
//打印输出
System.out.println("This is The First Application!");
System.out.println("The current time is: " + hour +
":" + minute + ":" + second);
System.out.println("3 + 5 = " + (3 + 5));
}
}
例2:
import java.util.Calendar;
public class FirstApplication
{
//应用程序主方法
public static void main(String args[])
{
//变量声明
int hour, minute, second;
Calendar calendar = Calendar.getInstance();
//变量赋值
hour = calendar.get(Calendar.HOUR_OF_DAY);
//获得小时
minute = calendar.get(Calendar.MINUTE); //获得分
second = calendar.get(Calendar.SECOND); //获得秒
//打印输出
System.out.println("This is The First Application!");
System.out.println("The current time is: " + hour +
":" + minute + ":" + second);
System.out.println("3 + 5 = " + (3 + 5));
}
}
这两个有区别吗?为什么例2能运行,例1却不能运行