Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Performance of Type Casting and Conversions

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Performance of Type Casting and Conversions

    Hello all,

    Search around these forums for ( "type casting" | "typecasting" ) and didn't scare up much. [EDIT]If I searched for the wrong thing, could you point me in the right direction?[/EDIT]

    I've got a String of data which contains a decent amount of numerical fields. I'm going to try to keep everything Strings as far as that's possible, but what kind of performance surrounds type casting and conversions?

    Specifically:
    -------------------
    int to short

    /* I'd expect these next to be similar */
    String to int
    String to short
    String to byte

    /*Not sure about this one */
    String to float

    Thanks in advance,
    --Fritzoid


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Performance of Type Casting and Conversions

    Most modern day computers can do it so fast you wouldn't even notice. Instead, I'd focus on optimizing your algorithm instead worrying about the performance of individual commands. If you really need hi-speed performance, then Java may not be the language for you to do that task in. Note that i've run some pretty cpu intensive stuff that when I changed the algorithm has been able to reduce computation time by 100 fold or more (say, days to less than a second).

Similar Threads

  1. Java Variable Conversions
    By JavaPF in forum Java Programming Tutorials
    Replies: 2
    Last Post: June 23rd, 2009, 05:03 AM
  2. Cracking password in less number of Trials using brute forcea
    By xisstar in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 10th, 2009, 10:40 AM
  3. Type casting error in Java
    By Eric in forum Java Theory & Questions
    Replies: 3
    Last Post: December 13th, 2008, 03:11 PM
  4. Replies: 1
    Last Post: May 13th, 2008, 08:08 AM