|
-
Oct 22nd, 2003, 09:48 AM
#1
Thread Starter
Lively Member
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.
-
Oct 22nd, 2003, 10:14 AM
#2
#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
-
Oct 22nd, 2003, 04:24 PM
#3
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.
-
Dec 9th, 2003, 04:30 AM
#4
Frenzied Member
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..
-
Dec 10th, 2003, 08:10 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|