请问HASHTABLE的问题! createTable(table);private void createTable()throws Exception 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 新的:还是有错,说是SYMBOL不能识别import java.util.*;import java.io.*;public class HashTest{ private Hashtable table; public HashTest() { // super("Word Type Count"); table = new Hashtable(); createTable(); createOutput(); } private void createTable()throws Exception { BufferedReader br = new BufferedReader (new InputStreamReader(System.in)); String input = br.readLine(); StringTokenizer words = new StringTokenizer(input,"\n\t\r"); while ( words.hasMoreTokens() ) { String word = words.nextToken().toLowerCase(); if (talbe.containsKey(word)) { Integer count = (Integer)table.get(word); table.put(word,new Integer(count.intValue()+1)); } else table.put(word, new Integer(1)); }}private String createOutput() { // String output = ""; Enumeration keys = table.keys(); // iterate through the keys while ( keys.hasMoreElements() ) { Object currentKey = keys.nextElement(); System.out.println(currentKey+"\t"+table.get(currentKey)+"\n"); } System.out.println("size: " +table.size()+"\n"); System.out.println("isEmpty: "+table.isEmpty()+"\n"); } public static void main( String args[] ) { HashTest application = new HashTest(); } } 不行啊,方法调用早改了,手物,参数createTable(table);改了,该是 17,52行的错误,IDENTIFIER EXPECTED, 53 REQUIRED TO ADD A ]OR[ 在构造函数中createTable()方法的时候,\你是不是该捕获一下异常阿?try catch一下阿? 不是EXCEPTION的错,是根本不能COMPLY呢,连IDENTIFIER都有问题 no.15 lineprivate void createTable(table)throws Exceptiondescription: <identifier>expectedno.51 line }description: "]"expected 你看看15行createTable(table)后面是不是应该有个空格,然后再throws???? 1)构造函数 and Main() 需加:throws java.lang.Exception2)private String createOutput() --> private void createOutput() 3)createTable()中的 { if (talbe.containsKey(word)) ---> table (not 'talbe') { Integer count = (Integer)table.get(word); table.put(word,new Integer(count.intValue()+1)); }你用的jbuilder吧?再要是有此错误,建议你删了重来一个全新的 你好像把createOutput放到了class外,把createOutput上面那个{去掉 用Process对象执行一命令,如果获得其输出啊? 求救!!!Eclipse打包jar后运行报错!!! 面试题,接口的初始化~让人费解,那位大哥能解释解释 Eclipse下制作javabean 高手帮忙把这段c#代码翻译成java代码? 看下这个Main函数调用错在哪? 如何改变按钮的形状? 百分求C语言到Java代码的转换 大吓们帮忙看看下面的代码,传输文件时出现内容丢失 请问怎么在static的方法里调用另一个方法? 是去是留,背水一战;散去分数,只求一问;大侠救之,不胜感激:如何实现二进制文件的操作?(急,在线等!!!) 誰能給各簡單的例子
import java.util.*;
import java.io.*;
public class HashTest
{ private Hashtable table;
public HashTest()
{
// super("Word Type Count");
table = new Hashtable();
createTable();
createOutput();
}
private void createTable()throws Exception
{
BufferedReader br = new BufferedReader
(new InputStreamReader(System.in));
String input = br.readLine();
StringTokenizer words = new StringTokenizer(input,"\n\t\r");
while ( words.hasMoreTokens() ) {
String word = words.nextToken().toLowerCase();
if (talbe.containsKey(word))
{
Integer count = (Integer)table.get(word);
table.put(word,new Integer(count.intValue()+1));
}
else
table.put(word, new Integer(1));
}
}private String createOutput() {
// String output = "";
Enumeration keys = table.keys();
// iterate through the keys
while ( keys.hasMoreElements() ) {
Object currentKey = keys.nextElement();
System.out.println(currentKey+"\t"+table.get(currentKey)+"\n");
}
System.out.println("size: " +table.size()+"\n");
System.out.println("isEmpty: "+table.isEmpty()+"\n");
}
public static void main( String args[] )
{
HashTest application = new HashTest();
}
}
改了,该是 17,52行的错误,IDENTIFIER EXPECTED, 53 REQUIRED TO ADD A ]OR[
private void createTable(table)throws Exception
description: <identifier>expected
no.51 line }
description: "]"expected
3)createTable()中的 {
if (talbe.containsKey(word)) ---> table (not 'talbe')
{
Integer count = (Integer)table.get(word);
table.put(word,new Integer(count.intValue()+1));
}你用的jbuilder吧?再要是有此错误,建议你删了重来一个全新的