gpt4 book ai didi

Java - 找不到符号?

转载 作者:行者123 更新时间:2023-12-01 18:15:25 24 4
gpt4 key购买 nike

我在这里练习了一点,但我就是不明白。我声明了 ArrayList ns 但找不到它:错误:找不到符号 ns.Add(aa); 为什么?当然,我只是没有看到明显的东西。

import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.util.Random;
import java.util.*;
import java.io.*;


public class Pixels6 extends JFrame
{
static java.util.List ns = new ArrayList();


class PaintingComponent extends JPanel
{
public void paintComponent(Graphics g)
{
super.paintComponent(g);
setBackground(Color.black);
}
}

public static void main( String[] args ) throws InterruptedException, IOException

{
try
{
fl = new FileInputStream("test_for_java2.s8");
aa = fl.read();

javax.swing.Timer swTimer = new javax.swing.Timer( 10, new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
if (aa!=-1)
{
aa -= 128;
aa = -aa;
ns.Add(aa);
try
{aa=fl.read(); }
catch( IOException e )
{
System.out.println( "Access denied: " + e );
System.out.println( e );
}
}
else try
{fl.close();}
catch( IOException e )
{
System.out.println( "Access denied: " + e );
System.out.println( e );
}
} /// Action

}); /// Timer
swTimer.start();

} //try

catch( IOException e )
{
System.out.println( "Access denied: " + e );
System.out.println( e );
}


SwingUtilities.invokeLater( new Runnable()
{
public void run()
{
new Pixels6().setVisible(true);
}
});

} /// main

} /// Pixels6 extends JFrame

最佳答案

更改为

ns.add(aa);  //not ns.Add(aa);

java 是区分大小写的语言

关于Java - 找不到符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29940458/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com