gpt4 book ai didi

java - Java中的简单问题

转载 作者:行者123 更新时间:2023-12-02 00:40:38 25 4
gpt4 key购买 nike

有人能告诉我如何解决这个问题吗?

public class Kuular implements ActionListener {

ImageIcon f1 = new ImageIcon("C:\\Users\\Student\\Desktop\\pic1.jpg");
ImageIcon f2 = new ImageIcon("C:\\Users\\Student\\Desktop\\pic2.jpg");
ImageIcon f3 = new ImageIcon("C:\\Users\\Student\\Desktop\\pic3.jpg");
ImageIcon f4 = new ImageIcon("C:\\Users\\Student\\Desktop\\pic4.jpg");

List<ImageIcon> list1 = Arrays.asList(f1, f2, f3, f4);
List<ImageIcon> list2 = new ArrayList<ImageIcon>();

public void fs() {
Collections.shuffle(list1);
}

Kuular k = new Kuular();
k.fs();; // HERE

如何调用方法fs?谢谢!

最佳答案

添加一个main()方法并执行该类

public class Kuular implements ActionListener {

ImageIcon f1 = new ImageIcon("C:\\Users\\Student\\Desktop\\pic1.jpg");
ImageIcon f2 = new ImageIcon("C:\\Users\\Student\\Desktop\\pic2.jpg");
ImageIcon f3 = new ImageIcon("C:\\Users\\Student\\Desktop\\pic3.jpg");
ImageIcon f4 = new ImageIcon("C:\\Users\\Student\\Desktop\\pic4.jpg");

List<ImageIcon> list1 = Arrays.asList(f1, f2, f3, f4);
List<ImageIcon> list2 = new ArrayList<ImageIcon>();

public void fs() {
Collections.shuffle(list1);
}

public static void main(String[] args) {
Kuular k = new Kuular();
k.fs();
}
}

关于java - Java中的简单问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6483367/

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