Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By allaudin

Thread: String to Float conversion

  1. #1
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default String to Float conversion

    float a = (Float.valueOf(args[0])).floatValue();
    float b = (Float.valueOf(args[1]));
    both working ..whats the differece between the two ?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,511
    Rep Power
    5

    Default Re: String to Float conversion

    Float.valueOf(args[0]) and Float.valueOf(args[1]) both return a Float object. The first assignment uses the floatValue() method of the Float wrapper to return a float primitive. The second one converts the Float object to a float primitive via unboxing.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

Similar Threads

  1. long and float conversion
    By jomypgeorge in forum New To Java
    Replies: 4
    Last Post: 01-07-2011, 06:05 AM
  2. string to float
    By Sungron in forum New To Java
    Replies: 3
    Last Post: 02-02-2010, 09:23 AM
  3. String to Float
    By durahman in forum New To Java
    Replies: 2
    Last Post: 02-12-2008, 12:17 AM
  4. Float to String
    By mew in forum New To Java
    Replies: 4
    Last Post: 12-29-2007, 05:08 PM
  5. convert string to float
    By miss_dot in forum NetBeans
    Replies: 1
    Last Post: 11-14-2007, 11:26 PM

Posting Permissions

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