aspose file tools*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Equality help w/ HugeInteger project" Watch "Equality help w/ HugeInteger project" New topic
Author

Equality help w/ HugeInteger project

joshua dowdle
Greenhorn

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: 171
    
    5

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

http://download.oracle.com/javase/7/docs/api/java/lang/Object.html
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
 
Consider Paul's rocket mass heater.
 
subject: Equality help w/ HugeInteger project