BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-11-2009, 09:37 PM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Vectors-->addElement method is producing errors.

Please Login to Remove!

I'm using the BB Plug-In with Eclipse.

I'm currently trying to wrap my head around "Vectors". But the addElement method is producing errors. Every line that has the addElement method on it shows the following errors:
  • Syntax error on token(s), misplaced construct(s)
  • Syntax error on token "addElement",= expected after this token

This line is in the imports area at the top of my file.
Code:
import java.util.Vector;
Code:
	Vector vector = new Vector(3, 2);
	vector.addElement(new Integer(1));
	vector.addElement(new Integer(2));
	vector.addElement(new Integer(3));
	vector.addElement(new Integer(4));
Anyone have any ideas? It looks like every Vector example that I've been able to find.

TIA!
__________________
Don

Handspring Visor -> Handspring Visor Deluxe -> Palm Treo 650 on VZW -> Palm Treo 700p on VZW -> Blackberry Tour 9360 on VZW

Last edited by doni49 : 10-11-2009 at 09:50 PM.
Offline  
Old 10-11-2009, 10:55 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

I don't see anything wrong with the snippet above. My guess is that your problem is before this code.

Post a more complete snippet (like a complete method).
Offline  
Old 10-12-2009, 06:18 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
I don't see anything wrong with the snippet above. My guess is that your problem is before this code.

Post a more complete snippet (like a complete method).
I moved the snippet to the top of my code just to be sure it wasn't something before it (before I posted it last night).

Code:
package com.rim.samples.table_list_field;

import java.util.Vector;
import java.lang.String;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.i18n.*;

class TableListApp extends UiApplication
{
	Vector vector = new Vector(3, 2);
	vector.addElement(new Integer(1));
	vector.addElement(new Integer(2));
	vector.addElement(new Integer(3));
	vector.addElement(new Integer(4));

//  it continues beyond this, but I didn't see 
//  the need to continue past this point.
__________________
Don

Handspring Visor -> Handspring Visor Deluxe -> Palm Treo 650 on VZW -> Palm Treo 700p on VZW -> Blackberry Tour 9360 on VZW

Last edited by doni49 : 10-12-2009 at 06:21 AM.
Offline  
Old 10-12-2009, 07:27 AM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

You cannot perform these assignments here - they must be performed in a method or in the constructor for the class.

public TableListApp ()
{
vector.addElement(new Integer(1));
vector.addElement(new Integer(2));
vector.addElement(new Integer(3));
vector.addElement(new Integer(4));

}
Offline  
Old 10-12-2009, 08:36 AM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
You cannot perform these assignments here - they must be performed in a method or in the constructor for the class.

public TableListApp ()
{
vector.addElement(new Integer(1));
vector.addElement(new Integer(2));
vector.addElement(new Integer(3));
vector.addElement(new Integer(4));

}
Ok thanks. That explains it!
__________________
Don

Handspring Visor -> Handspring Visor Deluxe -> Palm Treo 650 on VZW -> Palm Treo 700p on VZW -> Blackberry Tour 9360 on VZW
Offline  
Closed Thread


Thread Tools

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.