gpt4 book ai didi

java - "Varaible"无法解析为变量

转载 作者:行者123 更新时间:2023-11-29 07:26:11 24 4
gpt4 key购买 nike

<分区>

我正在学习一个教程,我是新手,我需要帮助来解决这个问题。如果有人能解释为什么会出现此错误以及如何解决。

import java.util.*;
public class bucky {

public static void main(String[] args) {

String[] things = {"apples", "noobs", "pwnge", "bacon", "goATS"};
List<String> list1 = new java.util.LinkedList<String>();
for(String x : things)
list1.add(x);

String[] things2 = {"sausage", "bacon", "goats", "harrypotter"};
List<String> list2 = new java.util.LinkedList<String>();
for(String y : things2)
list2.add(y);

list1.addAll(list2);
list2 = null;

printMe(list1);
removeStuff(list1, 2,5);
printMe(list1);
reverseMe(list1);


}

//printMe method
private static void printMe(List<String> l) {
for (String b : l);
System.out.printf("%s ", b); //This is the line where I get the error
System.out.println();
}

//removeStuff method
private static void removeStuff(List<String> l, int from, int to) {
l.subList(from, to).clear();
}

//reverseMe method
private static void reverseMe(List<String> l) {
ListIterator<String> bobby = l.listIterator(l.size());
while(bobby.hasPrevious())
System.out.printf("%s ", bobby.previous());
}
}

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