This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Murach's Java Programming and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

j2ME: Problem with the List item selection  RSS feed

Sangeeta Vepa
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a list which when selected puts the selected value into a textfield. Now whenever i select from the list it gives "array index out of bounds" exception.
"java.lang.ArrayIndexOutOfBoundsException: 1 >= 0"
Please specify where am i wrong. In the calling function or when it is defined in "VKJItem".
This is what i am doing: when the button is pressed
// Get the record ID of the currently selected contact
int itemindexorder = orderItemSearchDisplay.getSelectedIndex();
int iditemorder = ((Integer)itemIDs.elementAt(itemindexorder)).intValue();
// Retrieve the CLIENT record from the database
VKJItem vkjitemorder = dbitem.getItemRecord(iditemorder);
// Initialize the CLIENT fields
//Set the current display to ITEM ENTRY SCREEN
catch(Exception e)
Code of VKJItem is as follows: Its a separate class. Is there any problem in "unpack" below.

import java.util.*;
public class VKJItem {

private String varitem, varpack, varrate;
public VKJItem(String i, String p, String r)
varitem = i;
varpack = p;
varrate = r;
public VKJItem(byte[] data) {
unpack(new String(data));
public void unpack(String data) {
int start = 0, end = data.indexOf(';');
varitem = data.substring(start, end);
start = end + 1;
end = data.indexOf(';', start);
varpack = data.substring(start, end);
start = end + 1;
varrate = data.substring(start, data.length());

public String pack() {
return (varitem + ';' + varpack + ';' + varrate);

public String getItemName() {
return varitem;

public String getItemPack() {
return varpack;
public String getItemRate() {
return varrate;
/* End of code

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!