Test a variable type

edited August 2016 in How To...


I have a code which get data from the CSV. file. There should be few empty or string among the floats. How can I test it? I use Table object to handle the data. If I get data from the table (getFloat, getInt or similar) there is a chance to get an error. How can I test without error?

Thank you.


  • edited August 2016 Answer ✓

    Table class defines these fields to represent missing or non-parsable values:


    protected String missingString = null;
    protected int missingInt = 0;
    protected long missingLong = 0;
    protected float missingFloat = Float.NaN;
    protected double missingDouble = Double.NaN;

    If another missing value is preferable over any of those defaults, we can change them respectively w/:

    setMissingString(), setMissingInt(), setMissingLong(), setMissingFloat(), setMissingDouble()

    For example: table.setMissingInt(MIN_INT); Then: *-:)

    int age = table.getInt("age");
    if (age == MIN_INT)  System.err.println("Invalid age!");
Sign In or Register to comment.