哪位大神可以帮我解释这个JAVA题目?
importjava.io.*;publicclasstest{publicstaticvoidmain(String[]args)throwsIOException{i...
import java.io.*;
public class test
{
public static void main(String[ ] args) throws IOException{
int year;
boolean IsLeapYear;
System.out.println("Enter the year:");
BufferedReader in =new BufferedReader(
new InputStreamReader(System.in));
year=Integer.parseInt(in.readLine());
IsLeapYear=((year%4==0 && year%100 != 0)||(year%400 == 0));
if (IsLeapYear)
{
System.out.print(year);
System.out.println( "is a leap year");
}
else
{
System.out.print(year);
System.out.println( " is not a leap year");
}
}
}
请详细帮我说明一下“throws IOException”和“
BufferedReader in =new BufferedReader(
new InputStreamReader(System.in));
year=Integer.parseInt(in.readLine());
”是什么意思? 展开
public class test
{
public static void main(String[ ] args) throws IOException{
int year;
boolean IsLeapYear;
System.out.println("Enter the year:");
BufferedReader in =new BufferedReader(
new InputStreamReader(System.in));
year=Integer.parseInt(in.readLine());
IsLeapYear=((year%4==0 && year%100 != 0)||(year%400 == 0));
if (IsLeapYear)
{
System.out.print(year);
System.out.println( "is a leap year");
}
else
{
System.out.print(year);
System.out.println( " is not a leap year");
}
}
}
请详细帮我说明一下“throws IOException”和“
BufferedReader in =new BufferedReader(
new InputStreamReader(System.in));
year=Integer.parseInt(in.readLine());
”是什么意思? 展开
展开全部
这个程序是判断闰年的吧!throws IOException是抛出异常
BufferedReader in =new BufferedReader(new InputStreamReader(System.in));是从键盘接受输入流
year=Integer.parseInt(in.readLine()); 是将接收到的流转换成整形!
BufferedReader in =new BufferedReader(new InputStreamReader(System.in));是从键盘接受输入流
year=Integer.parseInt(in.readLine()); 是将接收到的流转换成整形!
更多追问追答
追问
那如果要输入几个数字,应该怎样写?(以输入3个数字,让其从大到小输出为例)
追答
什么意思?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询