Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterator

 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to get the values of Principal and BillMonthYear ..how do i access the values...I am getting values as 0...
what do i put in lines 1,2 till line 5....??

thanks
 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Please indent your code properly, its almost unreadable.
2. The while loop that starts on line 49 ends at line 62, so if there are 3 rows in the database, you'll get 6 outputs (because the iterator will run with each row in the database)
3. You are only displaying the value of variable in the while loop which you never set so you'll get 0 as output. If you want the values of billMonthYear and principal, then you can change the code in the second while loop to
 
Harpreet Singh janda
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instance variables are always automatically initialized to default values and for the float the default value is 0. As you are not setting the value of "variable" so by default it's value will be 0.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15437
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question doesn't look like it has anything to do with the SCJP exam. I will move it to a more appropriate forum for you.

Please CarefullyChooseOneForum when you post a question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic