Question: 1. public static void read (String inFile, String [] lines){ try { Scanner read = new Scanner (new File (inFile)); lines = new String[read.nextInt()]; for

1.

public static void read (String inFile, String [] lines){

try {

Scanner read = new Scanner (new File ("inFile"));

lines = new String[read.nextInt()];

for (int i = 0; i < lines.length; i++) {

lines[i] = read.nextLine();

} } catch (IOException e){

System.out.println("can't read: " + inFile);

System.exit(-1); } }

public static void main (String [] args){

String [] lines = null; read ("in.txt", lines);

System.out.println(Arrays.toString(lines)); }

inFile:

3 Hey!

Hows it going?

Fun Stuff

The answer is: can't read: in.txt

I want to know,why ?

I think it should be [Hey!, Hows it going?, Fun Stuff]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!