hlp me

K

karthika

i have two things one is vector (vec) and a map ( map ) and the code
will be
for ( int i = 0;i<vec.size() ;i++ )
{
Class obj = ( Class )vec.get( i );
for ( Iterator it = map.keySet().iterator();it.hasNext();)
{
key = (String)it.next();
Class2 obj2 = ( Class2 )map.get( key );
if (!info.contains(obj2))
{
v1.add(obj);
}
else
v1.remove(obj);
}
}
}

here what would be the result. becoz i get the answers as a repeated
one.
Pleease help :-(
 
T

Timo Stamm

karthika said:
i have two things one is vector (vec) and a map ( map ) and the code
will be

The code is incomplete. You have a reference to "info" that is never
declared or explained anywhere.

What do you want to achieve?


Timo
 
O

Oliver Wong

karthika said:
i have two things one is vector (vec) and a map ( map ) and the code
will be
for ( int i = 0;i<vec.size() ;i++ )
{
Class obj = ( Class )vec.get( i );
for ( Iterator it = map.keySet().iterator();it.hasNext();)
{
key = (String)it.next();
Class2 obj2 = ( Class2 )map.get( key );
if (!info.contains(obj2))
{
v1.add(obj);
}
else
v1.remove(obj);
}
}
}

here what would be the result. becoz i get the answers as a repeated
one.
Pleease help :-(

Is your question "What output would this code produce?"? If so, why
don't you simply run it and see?

- Oliver
 
K

karthi

Timo said:
The code is incomplete. You have a reference to "info" that is never
declared or explained anywhere.

What do you want to achieve?


Timo

Sorry Timo,
Its not "info" The corrected code will be
for ( int i = 0;i<vec.size() ;i++ )
{
Class obj = ( Class )vec.get( i );
for ( Iterator it = map.keySet().iterator();it.hasNext();)
{
key = (String)it.next();
Class2 obj2 = ( Class2 )map.get( key );
if (!vec.contains(obj2))
{
v1.add(obj);
}
else
v1.remove(obj);
}
}

}
 
T

Timo Stamm

karthi said:
Sorry Timo,
Its not "info" The corrected code will be
for ( int i = 0;i<vec.size() ;i++ )
{
Class obj = ( Class )vec.get( i );
for ( Iterator it = map.keySet().iterator();it.hasNext();)
{
key = (String)it.next();
Class2 obj2 = ( Class2 )map.get( key );
if (!vec.contains(obj2))
{
v1.add(obj);
}
else
v1.remove(obj);
}
}

}

Sorry, I still don't know what you want to achieve.

You should explain what you want to do, and where your program fails. It
also would help (us _and_ you) to use meaningful variable names.


Timo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top