JAVA 包的问题 谢谢解答!!
各位大哥大姐好!!学生初学JAVA
给一个程序写了一个包,觉得有问题但是查不出来,请求帮助!
另外import 包后总是 NOT EXIST??
包://主要是实现数据输入
package liao.prefect.ecommerce;
import java.io.*;
public class ConsoleReader
{ ConsoleReader(){} //这里觉得有问题!!
public static String readLine(){
StringBuffer response=new StringBuffer();
try{
BufferedInputStream buff=new BufferedInputStream(System.in);
int in=0;
char inChar;
do{
in=buff.read();
inChar=(char)in;
if(in!=-1){
response.append(inChar);
}
}while((in !=-1)&(inChar !='\n'));
buff.close();
return response.toString();
} catch(IOException e){
System.out.println("Exception:"+e.getMessage());
return null;
}
}
public static int readInt () //这个方法也不行!!!
{try{
BufferedInputStream buff=new BufferedInputStream(System.in);
int in=0;
char inChar;
do{
in=buff.read();
}while(in !=-1);
buff.close();
return in;
}
catch(IOException e){
System.out.println("Exception:"+e.getMessage());
return 0;}
} }
调用包:import liao.prefect.ecommerce.*;
public class Search
{
public static int[] Data=
{1,7,9,12,15,16,20,32,35,67,78,80,83,89,90,92,97,108,120,177};
public static int Counter =1;
public static void main(String[] args)
{
System.out.println("please enter your key value:");
ConsoleReader console =new ConsoleReader(System.in);//这个在包里怎么对应??
int KeyValue =console.readInt();
if(Seq_Search((int)KeyValue))
{
System.out.println("");
System.out.println("Search time ="+(int)Counter);
}
else
{
System.out.println("");
System.out.println("No found!!");
}
}
public static boolean Seq_Search(int Key)
{int i;
for(i=0;i<20;i++)
{
System.out.println("["+(int)Data[i]+"]");
if((int)Key==(int)Data[i])
return true;
Counter++;
}
return false;
}
}
另外我们学校老师在上数据结构(C 语言版)我该怎么处理,与JAVA的关系!!