BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 10-11-2009, 09:37 PM   #1
doni49
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
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
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
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
doni49
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
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
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
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
doni49
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Karcher Commodore Due Walk Behind Carpet Extractor #1.008-004.0 picture

Karcher Commodore Due Walk Behind Carpet Extractor #1.008-004.0

$9900.00



Jelenko Commodore LS VPF with Pump  picture

Jelenko Commodore LS VPF with Pump

$875.00



Windsor Commodore Duo 20

Windsor Commodore Duo 20" Carpet extractor w/Lester Charger 25900/Battery/99hour

$3595.95



Vintage Printer Switch box Commodore 64/Sanyo Mountable Computer PC picture

Vintage Printer Switch box Commodore 64/Sanyo Mountable Computer PC

$49.00



Sid Harveys Becket Commodore Rebuilt Motor A140-1R 1/8HP CCW 115V 1725 RPM picture

Sid Harveys Becket Commodore Rebuilt Motor A140-1R 1/8HP CCW 115V 1725 RPM

$31.99



Rare Untested Vintage Commodore 9R-23 Pocket Calculator, Manual & Case picture

Rare Untested Vintage Commodore 9R-23 Pocket Calculator, Manual & Case

$19.95







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