java的输入输出问题-我的程序为什么错? 是不是因为编码是unicode的原因呀?我还没有调试成功。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 读入字符串,然后再转为int型。 用Integer.parseInt();a 赋的值是一个字符串,应该定义一个int,然后用Integer.parseInt()使字符串转为int型我也是刚学,不好意思!也不太懂。 import java.io.* ;public class ch3{ public static void main(String args[]) throws IOException { DataInputStream in=new DataInputStream(System.in); String year; boolean b; System.out.print("请输入年份: "); year=in.readLine(); int a = Integer.parseInt(year); System.out.println("a="+a); b=(a%4==0&&a%100!=0)||a%400==0; System.out.println("b="+b); if(b==true) { System.out.println(a+"年是闰年"); } else { System.out.println(a+"年不是闰年"); } in.close(); }}这样可以通过,而且结果正确。 Java版另类 Hello World javaME问题求教 为什么线程只执行了一次 问一下short 转byte的问题 请教以下错误提示信息,谢谢! 有些网页是用*.cfm结尾的,是什么? 100分重拳出击,请教几个问题.能解答者,分数多多有加. 用JAVA实现PING程序 JFreeChart绘图问题 散分:>>>>>>>>>>>>>> 小问题肯定送分,关于interface 同样是一个在编译时的错误! 10个大洋,解释一条语句!!马上给分!!!
a 赋的值是一个字符串,
应该定义一个int,然后用Integer.parseInt()使字符串转为int型
我也是刚学,不好意思!
也不太懂。
public class ch3
{
public static void main(String args[]) throws IOException
{
DataInputStream in=new DataInputStream(System.in);
String year;
boolean b;
System.out.print("请输入年份: ");
year=in.readLine();
int a = Integer.parseInt(year);
System.out.println("a="+a);
b=(a%4==0&&a%100!=0)||a%400==0;
System.out.println("b="+b);
if(b==true)
{
System.out.println(a+"年是闰年");
}
else
{
System.out.println(a+"年不是闰年");
}
in.close();
}
}这样可以通过,而且结果正确。