devxlogo

Print “Hello World” in a Mobile Phone Using J2ME

Use a simulator to see the output:

import javax.microedition.midlet.*;import javax.microedition.lcdui.*;public class HelloWorld extends MIDlet implements CommandListener {    private Command exitCommand;    private TextBox tbox;    public HelloWorld() {        exitCommand = new Command("Exit", Command.EXIT, 1);        tbox = new TextBox("Hello world MIDlet", "Hello World!", 25, 0);        tbox.addCommand(exitCommand);        tbox.setCommandListener(this);    }    protected void startApp() {        Display.getDisplay(this).setCurrent(tbox);    }    protected void pauseApp() {}    protected void destroyApp(boolean bool) {}    public void commandAction(Command cmd, Displayable disp) {        if (cmd == exitCommand) {            destroyApp(false);            notifyDestroyed();        }    }}

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Five Early Architecture Decisions That Quietly Get Expensive

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.