Hola, I really wonder if a value of a member of a string array could serve as an index number for some other string array... Yes, an index of any array can only be int, but if an array of strings holds only numbers isn't it possible to go around this rule and have those numbers serve as indices? Example:
Would like numbers members to be indices for letters members, without parseInt...
Hmm....you don't have a Perl background, do you? The short answer...nope! You'll have to use parseInt or similar. Java is strongly typed, so where an 'int' is required, you gotta use an int (except as mentioned below). There are two circumstances under which some form of conversion is done automatically for you:
Some automatic casting is done between numeric types (specifically, between primitive types byte, short, int, char, float and double)
When using inheritance (I won't explain here, the explanation is not short, and is rather off-topic.
All other conversion you gotta do yourself... Cheers, --Tim [ April 20, 2004: Message edited by: Tim West ] [ April 20, 2004: Message edited by: Tim West ]
Joined: Feb 24, 2004
Casting a string to a byte array helped (getBytes() method), but code is far from elegant and from object oriented programing... Beside the casting that was previously mentioned, it also involves setting up an array for translating byte representation into the number that we started with (this time the number is int and not a string, and int is what I wanted)... if it is a double digit number, additional calculations apply...