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



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


Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013 picture

Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013

$37.90



NEW OEM Battery A1466 A1369 A1496 A1405 A1377 A1466 for MacBook Air 13 inch picture

NEW OEM Battery A1466 A1369 A1496 A1405 A1377 A1466 for MacBook Air 13 inch

$31.90



A1618 NEW OEM Battery for MacBook Pro 15

A1618 NEW OEM Battery for MacBook Pro 15" Retina A1398 Mid 2015 020-00079

$43.90



OEM iPhone 11 PRO X/XR XS MAX 8/7 PLUS Fast Charging USB Cable 10 Feet & 6 Feet  picture

OEM iPhone 11 PRO X/XR XS MAX 8/7 PLUS Fast Charging USB Cable 10 Feet & 6 Feet

$2.99



OEM Battery for MacBook Pro 17

OEM Battery for MacBook Pro 17" A1309 A1297 Early 2009 Mid 2009 2010 MC226

$36.90



NEW OEM A1618 Battery for Apple MacBook Pro 15” Retina 99.5Wh A1398 Mid 2015 picture

NEW OEM A1618 Battery for Apple MacBook Pro 15” Retina 99.5Wh A1398 Mid 2015

$43.90







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