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

一个关于类的问题,百思不得其解,多了一句输出就对了,高手来看看
高手们看看,我把System.out.println("请输入y:"); 注释掉它就报错了,什么原因啊?第一次发帖还望勿喷

import java.io.*;
class Dian
{
  int x;
  int y;
  public Dian()throws Exception
 {
  InputStreamReader isr=new InputStreamReader(System.in);
  BufferedReader br=new BufferedReader(isr);
  System.out.println("请输入x:"); 
  String s=br.readLine();
  x=Integer.parseInt(s);
  //System.out.println("请输入y:"); 
  s=br.readLine();
  y=Integer.parseInt(s);
 }
 void show()
 {
System.out.println("("+x+","+y+")");
 }
 public static void main(String args[])throws Exception
 {
 Dian dian1=new Dian();  
 dian1.show();
 }
}

------解决方案--------------------
我试过你的代码了 完全可以啊 楼主你自己再检查下 是软件问题还是操作失误了
------解决方案--------------------
程序没有问题
但是你的控制台输出的
“请输入x:” 和“ 3" 
不可能在同一行显示

------解决方案--------------------
你用命令行,不会出问题。。。我以前从eclipse里输入也出现问题的~命令行中不会出现任何问题