I am putting this code segment here.......Problem is, This loop is running only for i = 0, I dont know what is the problem.....Thanks in advance... -
-
for(int i = 0; i < v.size(); i++) {
-
while(itr.hasNext()) {
-
Map.Entry me = (Map.Entry)itr.next();
-
System.out.println("i::"+i);
-
if((((WorkPackageDetailsVO)v.get(i)).getWorkPackageName()).equals(((WorkPackageSummaryVO)me.getKey()).getWorkPackageName())) {
-
//System.out.println("i:"+i+" TRUE "+me.getKey());
-
String status = ((WorkPackageSummaryVO)me.getKey()).getCurrentDefectStatus();
-
String name = ((WorkPackageSummaryVO)me.getKey()).getWorkPackageName();
-
//System.out.println("----->>>"+status);
-
if(status.equals("On Work Plate"))
-
System.out.println("WorkPackageName: "+name+" Current Defect Status: "+status+" Count: "+((WorkPackageSummaryVO)me.getValue()).getCount());
-
else if(status.equals("Fixed"))
-
System.out.println("WorkPackageName: "+name+" Current Defect Status: "+status+" Count: "+((WorkPackageSummaryVO)me.getValue()).getCount());
-
else if(status.equals("Removed"))
-
System.out.println("WorkPackageName: "+name+" Current Defect Status: "+status+" Count: "+((WorkPackageSummaryVO)me.getValue()).getCount());
-
}
-
}
-
}
-
16 1984
It may be because of the number of entries in Iterator "itr". Probably it might have only one entry.
Can you just check on the number of entries actually present?
It may be because of the number of entries in Iterator "itr". Probably it might have only one entry.
Can you just check on the number of entries actually present?
I check it. Iterator has more than one element. But at the change of i from 0 to 1 while loop is not iterating again......I think at the change of i while loop should start from the begining.....I dont know why its happenin..
chech value of the v.size(), either this is not working or returned value is 1.
or
while(itr.hasNext()) check the return type of the itr.hasNext(), while loop will work till condition is true. This condition must return the boolean value.
chech value of the v.size(), either this is not working or returned value is 1.
or
while(itr.hasNext()) check the return type of the itr.hasNext(), while loop will work till condition is true. This condition must return the boolean value.
I check itr.hasNext()...for i = 1,2,3 it is returning false......but at the change of i the while loop should start from the begining....any suggestion??
I check itr.hasNext()...for i = 1,2,3 it is returning false......but at the change of i the while loop should start from the begining....any suggestion??
Is there any relationship between iter and v?
Is there any relationship between iter and v?
i.e Why are you using both a for and a while to do the looping?
i.e Why are you using both a for and a while to do the looping?
Actually v is a vector it contains workpackageNames.......So I am comparing name in vector and name in iterator......to get the no of counts corresponding to status in that workpackage.....plz tell me if there is any other way to do it......
Actually v is a vector it contains workpackageNames.......So I am comparing name in vector and name in iterator......to get the no of counts corresponding to status in that workpackage.....plz tell me if there is any other way to do it......
change your loops and put the for inside the while. Once the loop runs for the first i, iter.hasNext is no longer true for subsequent values of i.
I check itr.hasNext()...for i = 1,2,3 it is returning false......but at the change of i the while loop should start from the begining....any suggestion??
Hi
Your reply
itr.hasNext()...for i = 1,2,3 it is returning false......
while condition is returning a false value so it will not enter in the loop. It should return a true value.
itr.hasNext() is not working or the itr does not have any data. Check itr.
Hi
Your reply
itr.hasNext()...for i = 1,2,3 it is returning false......
while condition is returning a false value so it will enter in the loop. It should return a true value.
itr.hasNext() is not working or the itr does not have any data. Check itr.
The iterator could have values but it runs through all of them with i = 0 because of the next being called.
The iterator could have values but it runs through all of them with i = 0 because of the next being called.
If I initialize iterator after for loop and before while loop then, will it help me?........
I have already put for loop in while loop........but by doing that output was not according to requirement.......
If I initialize iterator after for loop and before while loop then, will it help me?........
I have already put for loop in while loop........but by doing that output was not according to requirement.......
Do you understand the logic of the next and hasNext methods?
See here - for (int i = 0; i < v.size(); i++) {
-
//i = 0;
-
while (iter.hasNext()) {
-
....iter.next();
-
}
-
//while is done => iter.hasNext() is false
-
//now when the for index changes to 1, the while loop is not entered
-
//any more because iter.hasNext() is false;
-
}
Do you understand the logic of the next and hasNext methods?
See here - for (int i = 0; i < v.size(); i++) {
-
//i = 0;
-
while (iter.hasNext()) {
-
....iter.next();
-
}
-
//while is done => iter.hasNext() is false
-
//now when the for index changes to 1, the while loop is not entered
-
//any more because iter.hasNext() is false;
-
}
My last reply was half........here v is Vector and iterator is for HashMap
Anyway....got your point......Now its done.....Thanks a lot.....
hi. there..
how to use while loop in java using an exit?....
my problem is, i can not exit the program using the loop given to me...
please help me.....
hi. there..
how to use while loop in java using an exit?....
my problem is, i can not exit the program using the loop given to me...
please help me.....
inside while loop put a condition when u want to exit........in that condition give System.exit(0)..........
inside while loop put a condition when u want to exit........in that condition give System.exit(0)..........
Don't use System.exit(0) unnecessarily. Instead try having a boolean variable as a "flag" and have a conditional execution based upon its value. Make sure you set the flag variables value once you have reached the condition. Use the features sparingly. Just because its present does not mean you can use everywhere.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Xiaozhu |
last post by:
I trid to use icc -axW to optimize the code, but it becomes much slower...
8sec/37sec before and after using this option.
my cpu is Intel(R) Pentium(R) 4 CPU 2.40GHz
the test code is just one...
|
by: Carmine Cairo |
last post by:
Hi,
I'm working on a project and today I've note a little problem during the
compile fase.
Here a little piece of code:
// 1st version
welldone = 0;
size = p->getSize();
backbone = new...
|
by: Jeff |
last post by:
Hello everybody,
I was doing one of the exercises in the K&R book, and I got something
really strange. Here's the source code:
/*
* Exercise 2-2 from the K&R book, page 42
*/
#include...
|
by: fb |
last post by:
Hi Everyone. Thanks for the help with the qudratic equation problem...I
didn't think about actually doing the math...whoops. Anyway... I'm
having some trouble getting the following program to...
|
by: Promextheus Xex |
last post by:
First php post...
Hi there,
I'm writing some code for my website to list people listening to my music. I
have a loop for an array that dosen't seem to display all people. most of
the time it...
| |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |