[問題] 編譯有問題?
我按照書上程式照著輸入
檢查過沒有打錯字
編譯卻有錯誤
不知道問題出在哪
請高手幫我看看 謝謝
原程式如下:
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)
→
07/27 14:26, , 1F
07/27 14:26, 1F
→
07/27 14:42, , 2F
07/27 14:42, 2F
→
07/27 14:43, , 3F
07/27 14:43, 3F
→
07/27 14:52, , 4F
07/27 14:52, 4F
→
07/27 15:01, , 5F
07/27 15:01, 5F
→
07/27 15:04, , 6F
07/27 15:04, 6F
→
07/27 15:16, , 7F
07/27 15:16, 7F