ucha ucha - 1 month ago 10x
Java Question

Arrays.asList cannot be resolved to a type

I'm trying to understand the logic behind list. So i am trying to make a simple program that finds the keyword "java" in the list and gives a feedback.

In the part of

List<String> thisIsAList = new Arrays.asList
, it throws an error "Arrays.asList cannot be resolved to a type".

Where am i making an error?

import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;

public class StringDemo {

public static void main(String[] args){

List<String> thisIsAList = new Arrays.asList(
,"Web Service"
, "ROS"
, "JVM"
, "MultiSegments"
, "JavaScript"
, "Purple"
, "Blue"
, "Yellow"
, "Dark"
, "Bright"
, "Light");

System.out.println("There exists Java word");
System.out.println("No Java word exists");



The new keyword is used specifically for instantiating objects. Since Arrays.asList is a method, not a class, you don't include new since need to simply invoke the method instead of trying to instantiate it.