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

一个小小的跳出循环问题,请教一下,在线等!!
public class ATMTest
{
  public static int readDate() throws IOException
  {
  //此处有代码
  while(true)
  {
  //此处有代码
  if()return 1;
  else if()return 0;
  else return 3;

  }
  }
  public static void main(String[] args)
  {
  switch(readDate())
  {
  case 1:------
  case 0:-----
  default:-----
  }
  }
}
就是这样,我想用readDate()函数通过判断条件传递给主函数中的switch几个int值,但是编译不通过,显示的是readDate()函数没有返回值,求解,在线等!

------解决方案--------------------
readDate()函数的返回值应该没有问题。。。
UserInfo.txt可能没在你的编译目录下,可以试试绝对路径,比如E:/UserInfo.txt
------解决方案--------------------
方法内的最后一行