Hi, can anybody help me in explaining the following question from K&B book chapter 6, Q 12:
import java.io.*;
class Directories {
static
String [] dirs = {"dir1", "dir2"};
public static void main(String [] args) {
for (String d : dirs) {
// insert code 1 here
File file = new File(path, args[0]);
// insert code 2 here
}
}
}
and that the invocation :
java Directories file2.txt
is issued from a directory that has two subdirectories, "dir1" and "dir2", and that "dir1" has a file "file1.txt" and "dir2" has a file "file2.txt", and the output is "false true", which set(s) of code fragments must be inserted? (Choose all that apply.)
A. String path = d;
System.out.print(file.exists() + " ");
B. String path = d;
System.out.print(file.isFile() + " ");
C. String path = File.separator + d;
System.out.print(file.exists() + " ");
D. String path = File.separator + d;
System.out.print(file.isFile() + " ");
Answer: The ans is (a) and (b), while I tried to run it I am having the following errors:
D:\SST\Java\Directories.java:8: cannot find symbol
symbol : method println(java.lang.String,java.lang.String)
location: class java.io.PrintStream
System.out.println( path, "file1");
^
D:\SST\Java\Directories.java:13: cannot find symbol
symbol : method println(java.lang.String,java.lang.String)
location: class java.io.PrintStream
System.out.println(path,"file2");
^
2 errors
Tool completed with exit code 1
I am not getting why its giving error on println statement.Am I missing some silly thing here.
Thanks in advance
Swapnil
[ June 18, 2006: Message edited by: Swapnil Trivedi ]