Question: In JAVA Please Help. I asked this already but somebody answered in python. My code in JAVA is outputting in red as shown on the

In JAVA Please Help. I asked this already but somebody answered in python. My code in JAVA is outputting in red as shown on the left hand side but I need help to output my code where it shows on the right. My CODE ______import java.io.*;
import java.util.*;
public class SortCars {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("What car make are you looking for?");
String carMake = scanner.nextLine().trim();
List cars = new ArrayList>();
try (BufferedReader br = new BufferedReader(new FileReader("cars.txt"))){
String line;
while ((line = br.readLine())!= null){
if (line.startsWith(carMake)){
cars.add(line);
}
}
} catch (IOException e){
System.out.println("Error reading file: "+ e.getMessage());
return;
}
Collections.sort(cars);
if (cars.isEmpty()){
System.out.println("No cars found for the make: "+ carMake);
} else {
for (String car : cars){
System.out.println(car);
}
}
}
}
In JAVA Please Help. I asked this already but

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 Programming Questions!