import java.util.*;
import java.io.*;class fruit{
public String name;
public float price;
public int quantity;
fruit(String name, float price,int quantity){
this.name=name;
this.price=price;
this.quantity=quantity;
}
}
public class goumai{
public String readLine() throws IOException {
try {
String str =new BufferedReader(new InputStreamReader(System.in)).readLine();
}
catch(IOException nfe){
System.out.println(nfe.getMessage());
}
return(str); //错误地方
}
public static void main(String[] args){
fruit[] fr=new fruit[3];
fr[0]=new fruit("apple",2,100);
fr[1]=new fruit("pear",2,200);
fr[2]=new fruit("banana",3,100);
Hashtable hash=new Hashtable();
hash.put("A",fr[0]);
hash.put("B",fr[1]);
hash.put("C",fr[2]);
String str =new BufferedReader(new InputStreamReader(System.in)).readLine();
//StringReader red =new StringReader(String );
//String temp=red.read();
//Scanner read=new Scanner(System.in);
//String br=read.nextLine();
//String br=read.nextLine();
//Object obj=hash.get(br);
//System.out.println(obj.name);//
System.out.println(((fruit)hash.get(str)).name);
//System.out.println(br);
}
}
错误信息如下:
D:\java>javac goumai.java
goumai.java:24: cannot resolve symbol
symbol : variable str
location: class goumai
return(str);
^
我都要崩溃了,调完一个错误 ,又出现一大堆错误,我头都要炸了,帮看看
import java.io.*;class fruit{
public String name;
public float price;
public int quantity;
fruit(String name, float price,int quantity){
this.name=name;
this.price=price;
this.quantity=quantity;
}
}
public class goumai{
public String readLine() throws IOException {
try {
String str =new BufferedReader(new InputStreamReader(System.in)).readLine();
}
catch(IOException nfe){
System.out.println(nfe.getMessage());
}
return(str); //错误地方
}
public static void main(String[] args){
fruit[] fr=new fruit[3];
fr[0]=new fruit("apple",2,100);
fr[1]=new fruit("pear",2,200);
fr[2]=new fruit("banana",3,100);
Hashtable hash=new Hashtable();
hash.put("A",fr[0]);
hash.put("B",fr[1]);
hash.put("C",fr[2]);
String str =new BufferedReader(new InputStreamReader(System.in)).readLine();
//StringReader red =new StringReader(String );
//String temp=red.read();
//Scanner read=new Scanner(System.in);
//String br=read.nextLine();
//String br=read.nextLine();
//Object obj=hash.get(br);
//System.out.println(obj.name);//
System.out.println(((fruit)hash.get(str)).name);
//System.out.println(br);
}
}
错误信息如下:
D:\java>javac goumai.java
goumai.java:24: cannot resolve symbol
symbol : variable str
location: class goumai
return(str);
^
我都要崩溃了,调完一个错误 ,又出现一大堆错误,我头都要炸了,帮看看
解决方案 »
- java 非阻塞io 即nio无限循环问题,困扰很久了,csdn版主、 高手请进,开了一个贴,三天没有人回答,希望有高手帮助,拜谢了
- 如何求一个int型数的绝对值?
- 我是java的初学者,我想问一个关于TextField的问题
- SWT/JFacez中怎么取得Image图片的大小?
- 向大家请教J2SE5.0中APPLET小程序运行问题!真急死我了,弄来弄去就是不明白怎么回事!
- 急
- 累加和问题
- 怎么将应用程序的标记只放在系统栏里,就和QQ似的。
- Java读取XML
- Java程序怎么打包??谢谢!!!
- 如何判断一个字符串是否为合法的linux路径,并且判断目录的权限
- 如何将String转为int类型
这个就是一个可见性的问题了