Witam
chce zrobić program, który w tablicy ma pewne liczby oraz druga tablica litery
chce dodać do elementu tablicy np: 5
problem taki jak dodać tablice wielowymiarową do jave me i z niej odczytać
do mojego programu dodałem tablicę ale jej nie wyświetla
podaje kod
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package hello;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author komp_k
*/
public class HelloMIDlet extends MIDlet implements CommandListener {
private boolean midletPaused = false;
private Command exitCommand;
private Command backCommand;
private Form form;
private StringItem stringItem;
private List list;
private Form form1;
int[][] tablica = new int[4][7];
//tablica[0] = new int[3];
//tablica[1] = new int[2];
//tablica[2] = new int[1];
public HelloMIDlet() {
}
private void initialize() {
}
public void startMIDlet() {
switchDisplayable(null, getList());
}
public void resumeMIDlet() {
}
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
Display display = getDisplay();
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
}
}
public void commandAction(Command command, Displayable displayable) {
if (displayable == form) {
if (command == backCommand) {
switchDisplayable(null, getList());
}
} else if (displayable == form1) {
if (command == backCommand) {
switchDisplayable(null, getList());
}
} else if (displayable == list) {
if (command == List.SELECT_COMMAND) {
listAction();
} else if (command == exitCommand) {
exitMIDlet();
}
}
}
public Command getExitCommand() {
if (exitCommand == null) {
exitCommand = new Command("Exit", Command.EXIT, 0);
}
return exitCommand;
}
public Form getForm() {
if (form == null) {
form = new Form("Welcome", new Item[]{getStringItem()});
form.addCommand(getBackCommand());
form.setCommandListener(this);
}
return form;
}
public StringItem getStringItem() {
if (stringItem == null) {
stringItem = new StringItem("Hello", "Hello, World!");
}
return stringItem;
}
public Command getBackCommand() {
if (backCommand == null) {
backCommand = new Command("Back", Command.BACK, 0);
}
return backCommand;
}
public List getList() {
if (list == null) {
list = new List("list", Choice.IMPLICIT);
list.append("List Element 1", null);
list.append("List Element 2", null);
list.addCommand(getExitCommand());
list.setCommandListener(this);
list.setSelectedFlags(new boolean[]{false, false});
}
return list;
}
public void listAction() {
String __selectedString = getList().getString(getList().getSelectedIndex());
if (__selectedString != null) {
if (__selectedString.equals("List Element 1")) {
switchDisplayable(null, getForm());
} else if (__selectedString.equals("List Element 2")) {
switchDisplayable(null, getForm1());
}
}
}
public Form getForm1() {
if (form1 == null) {
form1 = new Form("form1");
int i;
int j;
for(i=0; i< tablica.length; i++)
for(j=0; j< tablica[i].length; j++)
tablica[i][j] = 0;
form1.append(tablica[i][j]);
form1.addCommand(getBackCommand());
form1.setCommandListener(this);
}
return form1;
}
/**
* Returns a display instance.
*
* @return the display instance.
*/
public Display getDisplay() {
return Display.getDisplay(this);
}
/**
* Exits MIDlet.
*/
public void exitMIDlet() {
switchDisplayable(null, null);
destroyApp(true);
notifyDestroyed();
}
/**
* Called when MIDlet is started. Checks whether the MIDlet have been
* already started and initialize/starts or resumes the MIDlet.
*/
public void startApp() {
if (midletPaused) {
resumeMIDlet();
} else {
initialize();
startMIDlet();
}
midletPaused = false;
}
/**
* Called when MIDlet is paused.
*/
public void pauseApp() {
midletPaused = true;
}
/**
* Called to signal the MIDlet to terminate.
*
* @param unconditional if true, then the MIDlet has to be unconditionally
* terminated and all resources has to be released.
*/
public void destroyApp(boolean unconditional) {
}
}
jeszcze nie miałem styczności z tablicami javame
dziękuje za odpowiedz