Results 1 to 3 of 3
  1. #1
    java_no1 is offline Member
    Join Date
    May 2011
    Location
    Bengaluru
    Posts
    14
    Rep Power
    0

    Default Hot to convert string to int ????

    hi every one.
    Plz tell me where m i doing mistake in my code(CONVERTING STRING TO INT)
    ------------------------------------------------------------------------------------
    <html>
    <body >
    <%!
    String s=request.getParameter("x");
    String s1=request.getParameter("y");
    int i = Integer.parseInt(s);
    int j = Integer.parseInt(s1);

    int add()
    {
    int sum=i+j;
    return sum;
    }

    %>
    The sum of two numbers:<%=add()%>

    </body>
    </html>

  2. #2
    judejegan is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default

    hi please check this code this can be work

    <html>
    <body >
    <%
    String s=request.getParameter("x");
    String s1=request.getParameter("y");
    int i = Integer.parseInt(s);
    int j = Integer.parseInt(s1);
    int sum = add(i,j);
    %>
    <%!
    int add(int i,int j)
    {
    int sum=i+j;
    return sum;
    }

    %>
    The sum of two numbers:<%=sum%>

    </body>
    </html>

  3. #3
    java_no1 is offline Member
    Join Date
    May 2011
    Location
    Bengaluru
    Posts
    14
    Rep Power
    0

Similar Threads

  1. convert string array to int
    By curioustoknow in forum New To Java
    Replies: 12
    Last Post: 02-07-2011, 08:32 AM
  2. Convert String to Binary
    By erakhman in forum New To Java
    Replies: 1
    Last Post: 09-01-2010, 08:25 AM
  3. convert obj to string
    By isme in forum New To Java
    Replies: 11
    Last Post: 06-14-2010, 10:54 AM
  4. How to convert a TextArea to a String?
    By Antonioj1015 in forum Java Applets
    Replies: 1
    Last Post: 10-16-2009, 05:23 PM
  5. trying to convert an interger to a string
    By matpj in forum New To Java
    Replies: 12
    Last Post: 01-15-2009, 10:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •