Hi,
    I would like to know which closing and which if statement is more advisable and why below mentioned conditions.



Condition1:
      while(iterator.hasNext())
            {
            roDetailsVO = (RODetailsVO) iterator.next();
               callableStatement = connection.prepareCall("{call testpac.test(?,?)}");
                callableStatement.setInt(1, roDetailsVO.getInboxHdrId());
                callableStatement.setInt(2, roDetailsVO.getUserId());     
                                 callableStatement.close();
                               }
      OR

Condition2:
    while(iterator.hasNext())
            {
            roDetailsVO = (RODetailsVO) iterator.next();
               callableStatement = connection.prepareCall("{call testpac.test(?,?)}");
                callableStatement.setInt(1, roDetailsVO.getInboxHdrId());
                callableStatement.setInt(2, roDetailsVO.getUserId());     
                               }
      callableStatement.close();   // closing commonly

Condition 3 
    if(count==0)
       System.out.println(“count value is zero ”);     

Condition 4 
   if(count==0){
             System.out.println(“count value is zero ”); 
    }

Kindly share some idea about this.

Thanks,

Condition 2 and condition 4 is more appropriate.
condition 2 is because, it reduces few steps in execution. This will also increase performance.
condition 4 is because, it helps in readability, used in debugging.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.