-what is the difference in identity and equality in programming. my proff pointed on this topic and is getting it in midterm.
-what are wrapper class? and what do they do? and how do we create them?
Thank you very much
Printable View
-what is the difference in identity and equality in programming. my proff pointed on this topic and is getting it in midterm.
-what are wrapper class? and what do they do? and how do we create them?
Thank you very much
Well, a wrapper class is like a convinience class for complicated and generally technical routines that you might want to run that helps remove clutter from your main files. For example, you might create a wrapper class for graphics that contains draw_rectangle and draw_triangle methods, instead of writing the code over and over again in your main program. In essence, a wrapper class "wraps" around long code to compress what you need to write in your main files.
I'm not sure if I understand the first question correctly, but I beleive that equality would be comparing two seperate data types or objects to see if they are syntactically equal, and identity would be checking to see if something is(or is an direct version of) itself. Hope this helps.
A simple example of a wrapper class is BufferedReader. It can wrap around any of several readers, like FileReader, and it provides simple methods like read() and readLine(). This greatly simplifies simple text input procedures.
Just a little note from a first year CE major :)
~misfit
For your first question, you basically asking what's the difference between "=" and "=="?
The first one ("=") is most often used to assign values to a variable such as:
int NoOfHands = 2;
The Second one ("==") is used to compare to values to see if the are equal and return a boolean value such as:
10 == 12 is false