DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
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.




Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links