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

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









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
Can find a solution or code for this - XML
J2ME code - MobileApplications
pls send code
Pls send code
J2ME code hint - MobileApplications
sourse code pls
j2me code - Java Beginners
pls review my code - Struts
Pls review my code - Struts
pls review my code - Struts
j2me code - Date Calendar
j2me code - MobileApplications
j2me code - MobileApplications
Executing code upon folder/drive access
Java Swing code for zoom in and out
code and specification u asked - Java Beginners
Addition of two numbers
java code 1 of 2
java code 1 of 2
C++ code to find Entropy
Commenting out your code - Java Tutorials
verify the code and give me the code with out errors
code for sending email using j2me
pls send me the code for login and register - Java Beginners
ModuleNotFoundError: No module named 'commented-out-code'
ModuleNotFoundError: No module named 'commented-out-code'
ModuleNotFoundError: No module named 'commented-out-code'
can u plz help out how to attach file directly & send to a particular mail id
Program to find no of metrics in a file ----- Java 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
Can i write JavaScript code in AjaxResponse Code ?
code
code
code
Code
code for this is
java code for accept city name and gives temparature,wind speed,humidity exts along with description
code
code
code
code
code
code
Code
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........
executing java program with 2 classes
Divide 2 numbers

Ads