When I type Arrays.sort(arr)
in Eclipse, I get this error Arrays cannot be resolved
and when I left click the red underlined Arrays
word I don't get import java.util.Arrays
as expected.
I installed JRE and JDK 1.8.0_20 and my Project build path is configured accordingly. What could be an issue?
Manually add the following line at the beginning of the .java
file; if a package
declaration is present add it right after it, otherwise add it at the start of the file (or to keep things organized, add it in alphabetic order with respect to other imports):
import java.util.Arrays;
Alternatively: type Ctrl+Shift+o to automatically import all the required dependencies.
java.util
is a core library, included in the JDK –
Deckhand I had the same issue in eclipse. I resolved it by changing the jdk compiler compliance level to 1.6 in the windows-->preferences-->java--->compiler.
If you want to call Arrays.sort(....) method. You need to call it inside the main method( or any method) of your program. Not in class level. Please make sure that.
met this error on using Arrays.asList(1,2,3,4); import java.util.Arrays; and giving me red squiggly lines saying The import java.util.Arrays cannot be resolvedJava(268435846) but compiling and running seems ok. so i just went closing and running again my IDE. then everything went ok.
© 2022 - 2024 — McMap. All rights reserved.