jeudi 1 décembre 2016

if condition on javaDb

I am trying to generate a set of data using javaDB. So I have something like the following in my code:

String gender[] = {"Male", "Female"};
String everFallenSick[] = {"Yes", "No"};
String sicknessType[] = {"Flu", "Fever", "KidneyProblem"};

String sql = "insert into ExpDB values('" + gender[rand.nextInt(2)] + "',"...);
if ((everFallenSick[rand.nextInt(2)]).equals("No")) {
                sicknessType[rand.nextInt(7)].equals("null");
            }

System.out.println(sql + "\n");
statement.executeUpdate(sql);

======================================== My question is that the "if" condition I set is not executed because I expect to always get a string "null" value in the column of "sicknessType" whenever "everFallenSick" has the value "No".

Please advise on the logical error. Thanks




Aucun commentaire:

Enregistrer un commentaire