SL8R.co.uk - Code Zone

Code, Code and Code

SL8R.co.uk - Code Zone header image 4

J2ME: Bounds checking of a List

May 8th, 2008 · No Comments

This short routine shows how to ensure a selected item in a list is within bounds. If the list is empty the getSelectedIndex will return -1. The index starts at zero whilst size() will start at 1.
// perform bounds checking
int iIndex = myList.getSelectedIndex();
int iCount = myList.size();
// debugging information
System.out.println(”Index: ” + iIndex + ” Size: ” [...]

[Read more →]

Tags: Code