Error Message


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Error Message

  1. #1
    anu Guest

    Error Message


    Hi!

    I have just started with Java and I wrote a very simple program of asking
    the user to input a value of a variable
    and then displaying it.
    The program adds a value of 48 to the varaible and displays it. If anyone
    knows why this is happening please
    let me know. I have initialized the variable to zero and it still doesnt
    work.

    Anu

  2. #2
    Paul Clapham Guest

    Re: Error Message


    anu <arunaa@rocketmail.com> wrote in message
    news:38da866d$1@news.devx.com...
    >
    > Hi!
    >
    > I have just started with Java and I wrote a very simple program of asking
    > the user to input a value of a variable
    > and then displaying it.
    > The program adds a value of 48 to the varaible and displays it. If anyone
    > knows why this is happening please
    > let me know. I have initialized the variable to zero and it still doesnt
    > work.
    >
    > Anu


    Did you do something like
    char x = (get char from input here);
    int i = x;
    ?
    If you did, then you are getting the Unicode value of the character input
    (for example, the Unicode value of '1' is 49). Try int i =
    Integer.parseInt(x);.

    P.S. It would be helpful if you posted the code that's causing your problem.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center