作者gh8811211 (妈!我上电视了)
看板java
标题[问题] 编译有问题?
时间Tue Jul 27 14:20:54 2010
我按照书上程式照着输入
检查过没有打错字
编译却有错误
不知道问题出在哪
请高手帮我看看 谢谢
原程式如下:
import java.io.*;
import java.util.*;
public class MatchParenthesis
{
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in);
System.out.println("请输入一段算式");
System.out.println("->");
String str = br.readLine();
LinkedList match = new LinkedLis();
for(int i=0; i<str.length(); i++)
if(str.charAt(i) == '(')
match.addFirst(new Charcter('('));
else if(str.charAt(i) == ')')
try
match.removeFirst();
catch(NoSuchElementException e)
{
System.out.print("左右括号数量不符, 右括号太少")
return;
}
if(match.isEmpty())
System.out.print("左右括号数量相符");
else
System.out.print("左右括号数量不符, 右括号太少")
}
}
使用javac MatchParenthesis.java 编译
显示以下错误:
Note: MatchParenthesis.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
使用javac MatchParenthesis.java -Xlint 编译
出现以下错误:
MatchParenthesis.java:18: warning: [unchecked] unchecked call to addFirst(E)
as a member of the raw type java.util.LinkedList
match.addFirst(new Character('('));
^
1 warning
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 211.76.60.204
※ 编辑: gh8811211 来自: 211.76.60.204 (07/27 14:21)
※ 编辑: gh8811211 来自: 211.76.60.204 (07/27 14:22)
1F:→ tkcn:1. 这是 warning 不是 error 2. 你的参考书太旧了 07/27 14:26
2F:→ gh8811211:所以? 07/27 14:42
3F:→ gh8811211:请问要改什麽地方呢 07/27 14:43
4F:→ darkk6:Generic 07/27 14:52
5F:→ gh8811211:不懂..所以我需要买一本新的书? 07/27 15:01
6F:→ tkcn:你需要改的部份那本书上没教,就这样 07/27 15:04
7F:→ sbrhsieh:main method 内第一行不是就错了? 07/27 15:16