#ff0000 5  2005 . - #000655  J2ME 
#def     J2ME   J2SE,     .      ,      J2ME .        50K    -      ,     J2SE.  ,        .       ,      .  .     MIDlet-.         - . 

package com.j2medeveloper.techtips;

import javax.microedition.lcdui.*;

public class BeforeSizeOptimization extends 
                                         BasicMIDlet {

    public static final Command exitCommand =
                         new Command( "Exit",
                                    Command.EXIT, 1 ); 

    public BeforeSizeOptimization(){
    }

    protected void initMIDlet(){
        getDisplay().setCurrent( new MainForm() );
    }

    public class MainForm extends Form {
        public MainForm(){
            super( "MainForm" );

            addCommand( exitCommand );
            append( textf );

            setCommandListener( new CommandListener(){
                public void commandAction( Command c,
                                       Displayable d ){
                    if( c == exitCommand ){
                        exitMIDlet();
                    }
                }
              }
            );

            setItemStateListener( 
                              new ItemStateListener() {
                public void itemStateChanged( 
                                           Item item ){
                    if( item == textf ){
                        AlertType.INFO.playSound(
                                        getDisplay() );
                    }
                }
              }
            );
        }

        private TextField textf =
                  new TextField( "Type anything", null,
                                 20, 0 );

    }
}

  ,       ,         J2ME . ,  ,  ,     : 

package com.j2medeveloper.techtips;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public abstract class BasicMIDlet extends MIDlet {

    private Display display;

    public BasicMIDlet(){
    }

    protected void destroyApp( boolean unconditional )
                    throws MIDletStateChangeException {
        exitMIDlet();
    }

    public void exitMIDlet(){
        notifyDestroyed();
    }

    public Display getDisplay(){ return display; }

    protected abstract void initMIDlet();

    protected void pauseApp(){
    }

    protected void startApp()
                    throws MIDletStateChangeException {
        if( display == null ){ 
            display = Display.getDisplay( this );
            initMIDlet();
        }
    }

}

      J2ME Wireless Toolkit,       4k. 

               .   ,        ?        "  "?       .        ,      . 

  -  .       ,   ,   . ,         " ". 

public class foo 
{
    // ionoi
}

  ,      200 .       .  MIDlet     .      CommandListener  ItemStateListener    MIDlet-.     (        ).   ,          .    commandAction  itemStateChanged    . 

    .       ,        . 

  -    . ,  ,   CLDC,      .   Hashtable  Vector       .         MIDP .  MIDlet   Form    ,       : 

mainForm = new Form( "MainForm" );
mainForm.addCommand( okCommand );
mainForm.setCommandListener( listener );

  -     . ,          .    - ,         .    ,    ,     .     ,    ,       ,    . ,   MIDlet,    BasicMIDlet      . 

  -    , ,   .      ,       .       . ,      ,        ,   .      .  MIDP      .    ,       .  MIDlet      com.j2medeveloper.techtips. 

        .     ,  "obfuscator",     .   obfuscator- - ""  ,     .      .    ,         .    obfuscator-  RetroGuard.    obfuscator  CLDC , ,       preverification ().    ,    ,  . 

       .   ,  ,   

int arr[] = { 0, 1, 2, 3 };

    : 

arr[0] = 0;
arr[1] = 1;
arr[2] = 2;
arr[3] = 3;

   ,   javap,     Java 2 SDK          (  -c).     ,        .        : 1.     ,         ; 2.      ,    jar  ,             getResourceAsStream. 

      .        .      MIDlet-: 

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class ASO extends MIDlet
                 implements CommandListener,
                            ItemStateListener {

    private Display display;
    private Form mainForm;
    private TextField mainFormTF =
                  new TextField( "Type anything", null,
                                 20, 0 );

    public static final Command exitCommand =
                         new Command( "Exit",
                                     Command.EXIT, 1 ); 

    public ASO(){
    }

    public void commandAction( Command c,
                               Displayable d ){
        if( c == exitCommand ){
            exitMIDlet();
        }
    }

    protected void destroyApp( boolean unconditional )
                    throws MIDletStateChangeException {
        exitMIDlet();
    }

    public void exitMIDlet(){
        notifyDestroyed();
    }

    public Display getDisplay(){ return display; }

    protected void initMIDlet(){
        mainForm = new Form( "MainForm" );
        mainForm.addCommand( exitCommand );
        mainForm.setCommandListener( this );
        mainForm.setItemStateListener( this );
        mainForm.append( mainFormTF );

        getDisplay().setCurrent( mainForm );
    }

    public void itemStateChanged( Item item ){
        if( item == mainFormTF ){
            AlertType.INFO.playSound( getDisplay() );
        }
    }

    protected void pauseApp(){
    }

    protected void startApp()
                    throws MIDletStateChangeException {
        if( display == null ){ 
            display = Display.getDisplay( this );
            initMIDlet();
        }
    }
}
