vendredi 15 juillet 2016

Multiple if statements within try block [duplicate]

This question already has an answer here:

I have try catch block and am writing multiple if else statements. I see that , when the if condition is false, the control is not going to else instead it goes to a catch block. Here is my code,

  try 
    {
           if(fname.contains("javier")
           {

               if(lname != null || lname.isEmpty())
               {
                  employee.setlname("perez");
               }
               else
               {
                   employee.setlname("No last  name");
               }
                sysout(name);
           }

          else
           {
                   --------------
                   -------------
            }
    }
  catch(Exception e)
    {

     print("caught exception");

    }

Now, whenever my if(lname != null || lname.isEmpty()) is false, it goes to the catch block.

Aucun commentaire:

Enregistrer un commentaire