代码是对的,但就是编译通不过,谁能告诉我该怎么弄?

helson赵子健 2013-05-27 10:07:31
import java.io.*;
class TransStream
{
public static void main(String[] args)
{
InputStream in = System.in;//字节流

InputStreamReader isr = new InputStreamReader(in);
BufferedReader bufr = new BufferedReader(isr);//字符流
String line = null;
while((line=bufr.readLine())!=null)
{
if("over".equals(line))
break;
System.out.println(line.toUpperCase());
}
bufr.close();
}

}
...全文
333 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
nickpro 2013-05-28
  • 打赏
  • 举报
回复
main函数抛出异常就行了啊
helson赵子健 2013-05-28
  • 打赏
  • 举报
回复
我知道原因了,我不能导io.*,而要下面的包一个个导,但是我不知道为什么要这样,我JDK1.7的
24K純帥 2013-05-28
  • 打赏
  • 举报
回复
LZ我用dos也没抱错啊,你那是JDK几的
菖蒲老先生 2013-05-28
  • 打赏
  • 举报
回复
为什么不下载个eclipse来学习?
sca4441479 2013-05-28
  • 打赏
  • 举报
回复
放在编译工具里没问题啊,除了提示要加上try catch
lcf 2013-05-27
  • 打赏
  • 举报
回复
怪了我怎么可以编译
LCore 2013-05-27
  • 打赏
  • 举报
回复
引用 楼主 tyuiof 的回复:
import java.io.*; class TransStream { public static void main(String[] args) { InputStream in = System.in;//字节流 InputStreamReader isr = new InputStreamReader(in); BufferedReader bufr = new BufferedReader(isr);//字符流 String line = null; while((line=bufr.readLine())!=null) { if("over".equals(line)) break; System.out.println(line.toUpperCase()); } bufr.close(); } }
package com.kiritor;

import java.io.*;

public class TransStream {
	public static void main(String[] args)  {
		InputStream in = System.in;// 字节流
		InputStreamReader isr = new InputStreamReader(in);
		BufferedReader bufr = new BufferedReader(isr);// 字符流
		String line = null;
		try {
			while ((line = bufr.readLine()) != null) {
				if ("over".equals(line))
					break;
				System.out.println(line.toUpperCase());
			}
			bufr.close();
		} catch (Exception e) {
			// TODO: handle exception
		}
		
	}

}

62,621

社区成员

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

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