Topic: 关于引用一个自定义类的问题

  Print this page

1.关于引用一个自定义类的问题 Copy to clipboard
Posted by: dalipoo
Posted on: 2005-04-06 13:11

我构造了一个Mylnput类,用于键盘输入,内容如下。编译已经生成class文件。但为什么在其它需要引用它的程序里没法找到它,现在两者是在同一文件夹下的!我把它的内容再张贴到需要引用的程序中,就可以运行通过!
只有这样才行吗?请高人指教!
//MyInput.java:Contain the method for reading int,double,and string values from the keyboard


import java.io.*;
public class MyInput
{

// Read a string from the keyboard
public static String readString()
{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in),1);

//Declare and initialize the string
String string=" ";

//Get the string from the keyboard
try
{
string=br.readLine();
}
catch(IOException ex)
{
System.out.println(ex);
}

//Return the string obtained from the keyboard
return string;
}

//Read an int value from the keyboard
public static int readInt()
{
return Integer.parseInt(readString());
}

//Read an double value from the keyboard
public static double readDouble()
{
return Double.parseDouble(readString());
}
}


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923