I use the code below to get all results from the database.
while(rs1.next()) {
for(int i = 1; i < columnsNumber; i++)
System.out.printf(rs1.getString(i)+" ");
System.out.println();
}
They come in form of:
1 google com null
2 facebook com null
3 youtube com null
4 bbc com uk
I want to not display the null value. Although still display rest of the record. Thank you!
if(rs1 == null), or addif(rs1 != null) System.out.printf(rs1.getString(i)+" ");. You may want to factor out the spaces in that case though.String cell = Optional.ofNullable(rs1.getString(i)).orElse(""); System.out.printf(cell +" ");NULL, what do you want to print instead???