在下面的代碼中,我在最後一行中得到編譯器錯誤:「類型列表不明確」(嘗試定義cgxHist列表)。我究竟做錯了什麼?什麼是Java中的'模糊類型'錯誤?
import java.awt.*;
import javax.swing.*;
import java.util.*;
public class drawr extends JPanel{
public static int animationSpeed=470;
public static int diameter = 50;
hBod allHBods[];
List<String> cgxHist = new ArrayList<String>();
我其實是想在列表中包含整數,但是當我嘗試「投」的列表,這樣,用<int>
更換<String>
,在該行的誤差變得令牌‘INT’「語法錯誤,此標記後預期的尺寸'。建議請。
不能使用''或代替
List
寫,因爲仿製藥不要不支持原始類型。例如,請參閱[此問題](http://stackoverflow.com/questions/2721546/why-dont-java-generics-support-primitive-types)瞭解更多信息。 – Mac看到這也http://stackoverflow.com/questions/36325277/why-does-system-out-printlnnull-give-the-method-printlnchar-is-ambiguo –