Results 1 to 5 of 5

Thread: parseInt function?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    95

    parseInt function?

    2 questions for ya guys:

    1) how to write your own parseInt function? just simple converting a string to a number?

    2) how to pass an "int" or "long" data type by reference in java?? Are there no pointers like C?

    thanx.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    #2 - No, there are no pointers in Java. All primitives are sent by value, not by reference. You'll need to use the appropriate wrapper class to pass a reference.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Even that is not possible, because the wrapper classes are read-only. Lack of proper references is one of the largest shortcomings of Java.

    1) Like in every other language. Go through the string from left to right, convert each character to its integer value, add it to the total. When moving on, multiply the total by the radix.
    But there's one in the java.lang.Integer class, why would you want a custom one?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    Originally posted by crptcblade
    #2 - No, there are no pointers in Java. All primitives are sent by value, not by reference. You'll need to use the appropriate wrapper class to pass a reference.

    This is possible to send the reference of Wrapper classes but because the value inside is not changable.. it's of no use..

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Right on top of things as usual.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

Posting Permissions

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



Click Here to Expand Forum to Full Width