Ekaterina1234 Ekaterina1234 - 6 months ago 21
Java Question

Cannot find symbol - method getLength()

I'm trying to write a method that determines if the length of a string in a cell in a spreadsheet is longer than 15 chars, but it wont compile. I get the "Cannot find symbol - method getLength()" error. Does anyone know why I cant use this method?

enter image description here

import org.apache.commons.csv.*;

public class CSVfiles {
public void bigExporters(CSVParser parser, String amount) {
for (CSVRecord record: parser) {
String country = record.get("Country");
String amountDollars = record.get("Value (dollars)");
if (amountDollars.getLength() > 15) {
System.out.println(country);
}
}
}
}


EDIT

Thank those who do not down vote students' posts. We are here to learn, go easy on us newbs!

Thanks for all the answers!

Answer

Use .length() instead of .getLength()

if (amountDollars.length() > 15)