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.
Printable View
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 - 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.
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?
Quote:
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..
Right on top of things as usual.
:p