File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Equality help w/ HugeInteger project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Equality help w/ HugeInteger project" Watch "Equality help w/ HugeInteger project" New topic

Equality help w/ HugeInteger project

joshua dowdle

Joined: Nov 03, 2011
Posts: 1

OK, I'm in my first programming class and maybe I haven't paid enough attention, or it's quite possible i'm just not grasping all the info thrown at me. My project is to create a main driver class to instantiate two HugeInteger objects (25 element array) and exercise all the following HugeInteger methods: input, output, add, and equal. I think i have the beginning somewhat figured out, but for some reason i'm absolutely lost trying to find out if the two are equal. i just need another explanation that might help get my mind on the right track here. Any advice will greatly appreciated.

Tina Smith
Ranch Hand

Joined: Jul 21, 2011
Posts: 208

I find the javadoc is a pretty useful tool when I'm wondering how to do something.
Check out the equals method.

Ask yourself "how do I know that a HugeInteger is the same as another HugeInteger".
For a String, "hi" is the same as "hi" but not the same as "goodbye" that is to say the same letters must be present in the same order. If they're not then the strings are different.

(Note for good programming practice you will also want to look at hashCode(), but that's mentioned a lot around here. )

And (as Campbell would say)
Welcome to the Ranch.

Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
I agree. Here's the link:
subject: Equality help w/ HugeInteger project
It's not a secret anymore!