-1

I want to convert letters in array to a list by addAll(); and asList(); methods but java seems to complain. I am not sure if the error is located where the arrow is pointed. How to solve it?

import java.util.* {

    public static void main(String[] args) {
        List<String> abcs = new ArrayList<>();
        slowa.add("a");
        slowa.add("b");
        slowa.add("c");
        System.out.println(abcs);
        
        String[] ne = new String[]{"d","e","f","g"}; //<--------
        List<String> convert = Arrays.asList(ne);
        Collections.addAll(abcs, ne);//to,from
        
        
        System.out.println(abcs);
            }
    

}

I get the following error: error

user4t48u
  • 1
  • 2
  • 2
    `new` is a Java keyword and you cannot name your variables, classes, etc., using it. – Tim Biegeleisen May 20 '22 at 08:13
  • thank you, but java still complains – user4t48u May 20 '22 at 08:14
  • What you see is the output, it's not an error message. It's just not the output you expect. Also, in the future [please do not upload images of code/data/errors when asking a question.](//meta.stackoverflow.com/q/285551) – Joachim Sauer May 20 '22 at 08:17
  • 1
    You declared a list called "abcs" then you used the name "slowa" and you should fix the syntax in the first lines (add ; in the import and declare a class ) – Kays Kadhi May 20 '22 at 08:19

0 Answers0