this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??

Ads
 

this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??

import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class add1 extends MIDlet implements CommandListener { private Form f; private Display disp; private Command result,ok; private TextField t1,t2; public add1() { f=new Form("Addtion of two numbers"); // result=new Command("Result",Command.OK,1); ok=new Command("Ok",Command.OK,1); t1=new TextField("enter the first number",null,50,TextField.NUMERIC); t2=new TextField("enter the second number",null,50,TextField.NUMERIC); f.append(t1); f.append(t2); // f.addCommand(result); f.addCommand(ok); disp.getDisplay(this).setCurrent(f);

}
public void startApp() {
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command command, Displayable displayable) {
    if(command.getCommandType()==command.OK)
    {
        Form f2=new Form("displaying result");
        String n=t1.getString();
        String cd=t2.getString();
        int n1=Integer.parseInt(n);
        int n2=Integer.parseInt(cd);
        int result=n1+n2;
        f2.append(String.valueOf(result));
        Command c3=new Command("back",Command.BACK,1);
        f2.addCommand(c3);
        f2.setCommandListener(this);
        disp.getDisplay(this).setCurrent(f2);

    }
}

}

View Answers

Ads









Related Tutorials/Questions & Answers:
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??
CAN U HELP ME TO CODE IN JSP FOR ONLINE VOTING SYSTEM
Advertisements
pls send code
Pls send code
sourse code pls
Java Swing code for zoom in and out
java code 1 of 2
java code 1 of 2
Commenting out your code - Java Tutorials
C++ code to find Entropy
Addition of two numbers
verify the code and give me the code with out errors
code for sending email using j2me
ModuleNotFoundError: No module named 'commented-out-code'
ModuleNotFoundError: No module named 'commented-out-code'
ModuleNotFoundError: No module named 'commented-out-code'
Can i write JavaScript code in AjaxResponse Code ?
Program to find no of metrics in a file ----- Java code
can u plz help out how to attach file directly & send to a particular mail id
code
Code
code
code
fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below pls correct my code
code
code
code
code
Code
code

Ads