Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Super Contributor
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
My Carrier: TT
Accepted Solution

Does anyone know any replacement method for ArrayList

Purpose:

Using a method to add Byte element.

 

Problem:

Tyr to use Vector or ByteVector, but stop in Byte[].

 

origianl code

public ArrayList<Byte> cpu_config = new ArrayList(<Byte>);

public void setConfigInt(char key, int value) {
//To Add Elements
cpu_config.add(new Byte((byte)key));
byte arr[] = Util.itob(value);
cpu_config.add(new Byte(arr[0]));
cpu_config.add(new Byte(arr[1]));
cpu_config.add(new Byte(arr[2]));
cpu_config.add(new Byte(arr[3]));
}

 

Does anyone know any replacement method?

 

Thanks your attention.

 

-Fight with BB10
Highlighted
Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Does anyone know any replacement method for ArrayList

Hi @

 

Take a look at the ByteBuffer API:

www.blackberry.com/developers/docs/5.0.0api/java/nio/ByteBuffer.html

 

Hope that helps,

 

E.

Super Contributor
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
My Carrier: TT

Re: Does anyone know any replacement method for ArrayList

 

public ByteVector cpu_config = new ByteVector();

 

public void setConfigInt(char key, int value) {

//ByteVector method
cpu_config.addElement((byte) key);
byte[] arr = Util.itob(value);
cpu_config.addElement((arr[0]));
cpu_config.addElement((arr[1]));
cpu_config.addElement((arr[2]));
cpu_config.addElement((arr[3]));

}

 

Solved.

 

Cheers,

 

-Fight with BB10