DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: reading Integer

  1. #1
    Siz Guest

    reading Integer


    I'm new to java!
    I'm reading integer here is the code I'm using!
    and it always get different than what I enter.
    Can anyone help me in this!

    what is the best way to read integer!
    when I trace RO value it is fixed so I didn't get whats the problem!!!
    ===========================
    System.out.println("Enter the number of rows of the first matrix:");

    InputStreamReader rr = new InputStreamReader(System.in);
    BufferedReader bf1 = new BufferedReader(rr);
    String dV1 = new String(bf1.readLine());
    char dd1= dV1.charAt(0); int RO= dd1;

  2. #2
    Paul Clapham Guest

    Re: reading Integer


    Siz <sizhnorr@hotmail.com> wrote in message news:38dac27f@news.devx.com...
    >
    > I'm new to java!
    > I'm reading integer here is the code I'm using!
    > and it always get different than what I enter.
    > Can anyone help me in this!
    >
    > what is the best way to read integer!
    > when I trace RO value it is fixed so I didn't get whats the problem!!!
    > ===========================
    > System.out.println("Enter the number of rows of the first matrix:");
    >
    > InputStreamReader rr = new InputStreamReader(System.in);
    > BufferedReader bf1 = new BufferedReader(rr);
    > String dV1 = new String(bf1.readLine());
    > char dd1= dV1.charAt(0); int RO= dd1;


    When you do "int RO=dd1" you are _casting_ a char to an int. This gives the
    int the Unicode value of the char. For example, the Unicode value of '1' is
    49. Try int RO = Integer.parseInt(dd1);.




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