You Are Here:

Community: Developer Discussion Boards

#1 Old Question problems with vectors - 2007-06-21, 11:40

Join Date: Jun 2007
Posts: 27
Location: Jena, Germany
Send a message via ICQ to A.Vogel
A.Vogel
Offline
Registered User
Hi,

i have a little problem with filling a vector.

Here is a easy example of my problem.

1. I fill a vector with a string array containing two values:
Code:
for(int i = 0; i<10; ++i){
        test[0] = "Test";
	test[1] = " "+ i;
	vector.addElement(test);
}
2. I want to get the string array back from the vector:
Code:
for(int i = 0; i<10; ++i){
	String[] test2 = (String[])vector.elementAt(i);
	System.out.println("[0]" + test2[0]);
	System.out.println("[1]" + test2[1]);
}
!!The problem:

The strings I get back are not like:

[0] Test
[1] 1
[0] Test
[1] 2
[0] Test
[1] 3
.
.
.
[0] Test
[1] 9

They are only ten times
[0] Test
[1] 9

So i think the first for loop adds only ten times the same object to the vector.

Can anybody help me.

Greetings
Alex
Reply With Quote

#2 Old Thumbs up Re: problems with vectors - 2007-06-21, 12:40

Join Date: Jun 2007
Posts: 27
Location: Jena, Germany
Send a message via ICQ to A.Vogel
A.Vogel
Offline
Registered User
OK I've got the solution.

I had to define the string array test localy in the first loop and not global on the MIDlet.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
CTelephony Problems in N73 saji_iq Symbian Networking & Messaging 0 2007-02-07 08:57
Several problems with NMIT 4.1 jtalviva General Browsing 1 2006-03-20 14:00
Several problems with NMIT 4.1 MMS jtalviva General Messaging 0 2006-03-10 12:03
Several problems with NMIT 4.1 jtalviva Mobile Java Tools & SDKs 0 2006-03-10 11:59
Problems with Nokia carkit CK-1W Batunas General Discussion 1 2004-02-09 19:18

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia