| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 830 人关注过本帖
标题:刚学Java,请帮忙看看这两个类,为什么会显示找不到符号
只看楼主 加入收藏
一二三四
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2007-12-2
收藏
 问题点数:0 回复次数:2 
刚学Java,请帮忙看看这两个类,为什么会显示找不到符号
包都是用的import java.*
public class InputReader
{
    public HashSet<String>getInput()
    {
        System.out.print("> ");
        String inputLine=reader.nextLine().trim().toLowerCase();
        String[] wordArray=inputLine.split(" ");
        HashSet<String>words=new HashSet<String>();
        for(String word:wordArray){
            words.add(word);
        }
        return words;
    }
}
public class Responder
{
   
   public Responder()
   {
       responseMap=new HashMap<String,String>();
       fillResponseMap();
    }
   private void fillResponseMap()
   {
       responseMap.put("slow","I think this has to do with your hardware.\n");
       responseMap.put("bug","Well,you know,all software has some bugs.\n");
       responseMap.put("expensive","The cost of our product is quite competitive.\n");
    }
   public String generateResponse(HashSet<String> words)
   {   
       Iterator<String> it=words.iterator();
       while (it.hasNext())
       {
       String word=it.next();
       String response=responseMap.get(word);
           if(response!=null){
               return response;
            }
        }
        return pickDefaultResponse();
    }
   public String pickDefaultResponse()
   {
       return("I need more information.");
    }
}
搜索更多相关主题的帖子: Java String 符号 public Responder 
2008-05-14 23:13
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
可以编译通过了
import java.*;
import java.util.*;
 class InputReader
{
    public HashSet<String>getInput()
    {
        System.out.print("> ");
        Scanner sc = new Scanner(System.in);
        String inputLine=sc.nextLine().trim().toLowerCase();
        String[] wordArray=inputLine.split(" ");
        HashSet<String>words=new HashSet<String>();
        for(String word:wordArray){
            words.add(word);
        }
        return words;
    }
}
 class Responder
{  
   HashMap<String,String> responseMap;
   
   public Responder()
   {
       responseMap=new HashMap<String,String>();
       fillResponseMap();
    }
   private void fillResponseMap()
   {
       responseMap.put("slow","I think this has to do with your hardware.\n");
       responseMap.put("bug","Well,you know,all software has some bugs.\n");
       responseMap.put("expensive","The cost of our product is quite competitive.\n");
    }
   public String generateResponse(HashSet<String> words)
   {   
       Iterator<String> it=words.iterator();
       while (it.hasNext())
       {
       String word=it.next();
       String response=responseMap.get(word);
           if(response!=null){
               return response;
            }
        }
        return pickDefaultResponse();
    }
   public String pickDefaultResponse()
   {
       return("I need more information.");
    }
}

学习需要安静。。海盗要重新来过。。
2008-05-15 09:51
一二三四
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2007-12-2
收藏
得分:0 
谢谢
2008-05-15 09:59
快速回复:刚学Java,请帮忙看看这两个类,为什么会显示找不到符号
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031004 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved