variable values in loops

Discussion in 'Java' started by champion, Jun 29, 2007.

  1. champion

    champion New Member

    Joined:
    May 29, 2007
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Analyst Programer
    Location:
    Harare, Zimbabwe
    Code:
    //Define Iterator iter
    
    String policyPath = "";
    while (iter.hasNext()) 
    {
    deductionL = (DeductionsLocal) iter.next();
    
    String policyID = deductionL.getPolicyID();
    
    policyL = policyH.findByPrimaryKey(policyID);
    
    if(policyL.getStatus().equalsIgnoreCase("READY TO GO INTO FORCE")||policyL.getStatus().equalsIgnoreCase("IN FORCE"))
    	policyPath = "/NewBusiness/displayPolicyApproved.jsp"; 
    else
    	policyPath = Utils.getPolicyPath(policyL.getNextAction());
    
    
    
    //other code
    //end loop
    }
    why is it that policyPath has nothing for the rest of the iterations?
     
    Last edited by a moderator: Jun 29, 2007
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    How this becomes as your introduction.
     
  3. champion

    champion New Member

    Joined:
    May 29, 2007
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Analyst Programer
    Location:
    Harare, Zimbabwe
    i did my introduction when i registered. this is my second post sir.
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Then you should be making the post in the relevant section. For now I could not get if its C# or Java so I have not moved it for you.
     
  5. champion

    champion New Member

    Joined:
    May 29, 2007
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Analyst Programer
    Location:
    Harare, Zimbabwe
    Its is Java (J2EE)

    thnaks
     
  6. champion

    champion New Member

    Joined:
    May 29, 2007
    Messages:
    9
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Analyst Programer
    Location:
    Harare, Zimbabwe
    Code Java J2EE

    if(policyL.getStatus().equalsIgnoreCase("READY TO GO INTO FORCE")||policyL.getStatus().equalsIgnoreCase("IN FORCE"))
    policyPath = "/NewBusiness/displayPolicyApproved.jsp";
    else
    policyPath = Utils.getPolicyPath(policyL.getNextAction());

    I have found why it was not retaining anything. it is because when the if is not executed the else is executed but it retains an empty string because the argument policyL.getNextAction was not catered for in my Utils.getPolicyPath. i have managed to impliment it. thanks guys.
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I have moved the thread to Java forum for better and faster responses.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice