0

CAN ANYBODY SOLVE THIS? Why error?

import java.io.File; import java.util.Date; public class Program { public static void main(String[] a[]) { File file = new File("/home/students") ; String[] filelist = file.list(); for(String name: fileList){ System.out.println(name); } } }

26th Oct 2022, 4:34 AM
Mustakim Rahman
Mustakim Rahman - avatar
7 Respuestas
+ 1
It shows cannot find symbol
26th Oct 2022, 6:25 AM
Mustakim Rahman
Mustakim Rahman - avatar
0
replace main(string[] arg[]) by main(string[] arg) file.list() throw SecurityExeption, you have too surround your code with a try/catch block What is your error?
26th Oct 2022, 5:48 AM
Roland
Roland - avatar
0
Have you try What I suggested ☝️ public static void main(String[] a)
26th Oct 2022, 8:12 AM
Roland
Roland - avatar
0
Mustakim Rahman Check spelling of 'fileList' and 'filelist' Also there should be: main(String[] a) You will get nullpointer exception
26th Oct 2022, 9:01 AM
A͢J
A͢J - avatar
0
list() can return null if the path in File() does not exist import java.io.File; import java.util.Date; public class Program { public static void main(String[] a) { File file = new File("/home/students") ; String[] fileList = file.list(); System.out.println( fileList); // if (fileList != null) { for( String name: fileList){ System.out.println(name); } } } }
26th Oct 2022, 9:54 AM
zemiak
0
Take care about path of your file relatively to project folder.
26th Oct 2022, 5:47 PM
Kate
0
I need help with the passport vehicle
28th Oct 2022, 2:00 AM
Michael Grant