Java newbie help (type casting, 64bit unsigned Long)

H

hochidsp

Hi I am java newbie and need help on my project. I have a few
questions. Can you put strings in a hashtable and test for their being
their with the appropriate hashtable method? I want to test for equal
strings, not the same object. Second question can you use all 64 bits
of an unsigned long? java doesn't seem to allow this. Any packages that
do?
Thanks,
Dave
 
A

Andrew McDonagh

Hi I am java newbie and need help on my project. I have a few
questions. Can you put strings in a hashtable and test for their being
their with the appropriate hashtable method? I want to test for equal
strings, not the same object. Second question can you use all 64 bits
of an unsigned long? java doesn't seem to allow this. Any packages that
do?
Thanks,
Dave

Any object can be used as either the Key or Value. The String object's
equals() method will be used to determine whether the search key is
found within the key set. Google Java String to see what the equals()
method does.

Java does not support unsigned longs or ints - they are all signed.

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html

If you need a bigger number than a (signed) long, then one way is to use
an array of bytes.
 
L

Lee Fesperman

Andrew said:
Any object can be used as either the Key or Value. The String object's
equals() method will be used to determine whether the search key is
found within the key set. Google Java String to see what the equals()
method does.

Java does not support unsigned longs or ints - they are all signed.

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html

If you need a bigger number than a (signed) long, then one way is to use
an array of bytes.

Try java.math.BigInteger. It's signed but you can values greater than 32-bits.
 
C

Chris Smith

Second question can you use all 64 bits
of an unsigned long? java doesn't seem to allow this.

Here's a slight modification to the answers you've already received.
Java has a 64-bit integer data type. Various operators and API
functions may treat it as either signed or unsigned, or they may work
with either. Something about your phrasing suggests that you want to
use the long as a bit mask... in that case, all operators are
independent of sign, except that >>> should be used instead of >>.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top