I have a problem with my if command. My variables are of String type the same type as the array values, but still the code won't step into the lines: if(values[0] == "Truck") and if(values[0] == "Order")
``` public ArrayList<ISP> read() {
String filePath = "file.csv";
ArrayList<ISP> ISPList = new ArrayList<>();
try {
// Through BufferedReader we want to read the data and we define a new
// FileReader using our filePath name
BufferedReader br = new BufferedReader(new FileReader(filePath));
// read first line of text
String line = br.readLine();
// As long as the next line isn't null
while (line != null) {
String[] values = line.split(COMMA_DELIMITER);
ISP.Truck truck = null;
ISP.Order order = null;
if (values[0] == "Truck") {
truck = createTruck(values);
ISPList.add(truck);
} else if (values[0] == "Order") {
order = createOrder(values);
ISPList.add(order);
}
// read next line
line = br.readLine();
} br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return ISPList;
}
```
can anyone help me find where is the problem?
Aucun commentaire:
Enregistrer un commentaire