Results 1 to 6 of 6
  1. #1
    JT4NK3D's Avatar
    JT4NK3D is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Default [SOLVED] What's the difference between parsing and casting?

    What is the difference between parsing (e.g. myint = Integer.parseInt(args[0])) and casting (e.g. myint = (int)args[0];). I'm just curious to know the difference because they seem to do the same thing.:)
    You just got T4NK3D!
    Adonrcicg to rcesraeh the haumn mnid is clbapae of rdanieg tihs. -Jvaa Sun Moricyssemts-

  2. #2
    Breadwinna is offline Member
    Join Date
    May 2008
    Posts
    2
    Rep Power
    0

    Default

    Parsing is converting strings to primitive data types such as 'int'

    Casting is just switching between different primitive data types I.E., 'int' to 'short'

  3. #3
    JT4NK3D's Avatar
    JT4NK3D is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Default

    but aren't you able to cast between objects, not just primitive data types?
    You just got T4NK3D!
    Adonrcicg to rcesraeh the haumn mnid is clbapae of rdanieg tihs. -Jvaa Sun Moricyssemts-

  4. #4
    JT4NK3D's Avatar
    JT4NK3D is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Default

    So parsing is just to change a string into a primitive data type, and casting can either cast between primitive data types or cast between objects?
    You just got T4NK3D!
    Adonrcicg to rcesraeh the haumn mnid is clbapae of rdanieg tihs. -Jvaa Sun Moricyssemts-

  5. #5
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    casting is an internal process that was designed to reduce overheads and execution errors.

    Parsing? It depends, i guess for sure, you may browse the file where the parse(Something) belongs... and see how the parsing method implemented....

    src file (ZIP) can be found on jdk folder....
    All built-in java classes can be found in that src file...
    freedom exists in the world of ideas

  6. #6
    JT4NK3D's Avatar
    JT4NK3D is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Default

    ok thanks :)
    You just got T4NK3D!
    Adonrcicg to rcesraeh the haumn mnid is clbapae of rdanieg tihs. -Jvaa Sun Moricyssemts-

Similar Threads

  1. Casting problem
    By John_28 in forum New To Java
    Replies: 6
    Last Post: 05-14-2008, 11:29 AM
  2. Casting an int value into a char
    By kurtulas in forum New To Java
    Replies: 2
    Last Post: 02-16-2008, 08:03 PM
  3. Type Casting Help
    By rhm54 in forum New To Java
    Replies: 2
    Last Post: 02-07-2008, 12:06 PM
  4. 'Casting' couch !!
    By ajaygargnsit in forum New To Java
    Replies: 1
    Last Post: 12-22-2007, 01:05 PM
  5. Casting
    By leebee in forum New To Java
    Replies: 5
    Last Post: 08-10-2007, 12:24 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
  •