wood burning stoves
The moose likes Java in General and the fly likes Iterator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Iterator" Watch "Iterator" New topic


maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 187
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....??

Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

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

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

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

Joined: Aug 16, 2005
Posts: 15092

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link: http://aspose.com/file-tools
subject: Iterator
It's not a secret anymore!