Could you help me in understanding what this code means ?

Hi, I was reading an article about Comparing Objects. Well, here's the link:
http://www.onjava.com/lpt/a/3286
The link I found it somewhere in this forum too...it's about sorting an array based on another sorted array...I can't understand what is happening inside this code...Well, I knew it is a method, because it actually a member of a class Person. The problem is that, everytime I delete this part of method in a class which implements Comparable...it always throws an error...is it possible if I don't use this method below ?
public int compareTo(Object anotherPerson) throws ClassCastException {
    if (!(anotherPerson instanceof Person))
      throw new ClassCastException("A Person object expected.");
    int anotherPersonAge = ((Person) anotherPerson).getAge(); 
    return this.age - anotherPersonAge;   
  }Thank you very much !
Sincerely,
Chris

Thank you, I am new in Java Programming, and my class will start talk about Sorting Array next week, and I know that I am so weak in Sorting things...so, I have to encourage myself, so that I could understand what they will discuss in the class....
//WHAT IS THE "!" sign before the anotherPerson instanceof Person means ?
if (!(anotherPerson instanceof Person))
      throw new ClassCastException("A Person object expected.");
* I know that Person is the class name and anotherPerson is an object of
* class Person but: ((Person)anotherPerson)...what is that mean ?
* so the getAge() method refers to anotherPerson's age ?
* or the Person's age ?
* Say that I don't want to sort it based on the age, but I want to sort it,
* for example:
* by its character's length, do I have to create a method to get the
* characters length ?
    int anotherPersonAge = ((Person) anotherPerson).getAge(); 
    return this.age - anotherPersonAge;
   }Thank you...
Chris

Similar Messages

  • Please help me to understand what is the meaning of Acess point Channel utilization?

           please help me to understand what is the meaning of Acess point Channel utilization? If i want to mange the capacity of my Office Wi-Fi network what are the factor i need to monitor.

    Hi Ankit,
    Channel Utilization
    The 802.11, 802.11b, and 802.11g standards use the same 2.4 GHz band. All must interoperate with each other, which introduces additional overhead reducing channel throughput. Many sites already have products using the Wi-Fi 2.4 GHz band. Additionally, there are many other products that use the same 2.4 GHz frequencies as used by Wi-Fi. Other products include Bluetooth, cordless phones, video game controllers, surveillance cameras, and microwave ovens.
    Before the installation of the Cisco Unified Wireless Network, a site can be tested for channel interference and utilization with tools from AirMagnet, Wild Packets, Cognio, and others. The Wireless Control System (WCS) AP On-Demand Statistics Display report provides a spectrum review of the following:
    •Noise by channel
    •Interference by channel
    •Client count versus RSSI
    •Client count versus SNR
    •Channel radar detection versus time
    You can further refer the following links,  
    https://supportforums.cisco.com/thread/2212228
    https://supportforums.cisco.com/thread/334981
    For design guide following link might help,  
    http://www.cisco.com/en/US/docs/solutions/Enterprise/Education/SchoolsSRA_DG/SchoolsSRA_chap5.html

  • HT5567 i have purchased the factory unlocked iphone 4, i found notification to update iOS 6.0.1 but i found the error massage when downloading is complete more than 50%, i am very worry about this, could you help me how to update this iOS in my iphone 4 3

    My iphone 4 (3G) cound not complete the installation of iOS 6.0.1 software update. please help me how can i update???

    "Software update failed
    An error occurred downloading iOS 6.0.1."
    this information shows after downloading starting some time left.

  • Can anyone help me figure out what this sighn means...?

    everytime i try to turn on my ipod the apple logo appears and then a battery with a exclemation mark in a litlle triangle appears, and once i got it on it won't play the songs, it just goes through them w/o playing it for a second. I can't figure it out. What should i do?

    So, what does the iPod show on the screen when you connect it to your power source?
    Have you tried resetting it while it's connected? To reset hold the MENU and SELECT (center) buttons until you see the Apple logo.

  • TS3694 i tried to reset/restore my daughters i pod but encountered problem 3194??Does anyone know what this code means?Ta

    can someone pls help me-tried to reset daughters i pod but problem code 3194 comes up.what does this mean???

    See the actions for that error here:
    iTunes: Specific update-and-restore error messages and advanced troubleshooting
    iPhone Error 3194 - How to Fix iTunes Error 3194?
      Fix Error 3194 from iTunes during iPhone restore

  • Regarding replacement path.. Could you help me please .. ?

    Dear all,
    I have problem when i use variable replacement path, where it replace another variable.
    The scenario is like this:
    I have variable cal. month user input where the type is interval (let say it's called var A).
    Then i create rep. path variable cal. month:
    1. Replace with : Key
    2. Use Interval : From Value.
    I use this rep. path variable for restricted KF.
    When i run the report:
    I fill in the value for Var A:
    01.2003 - 05.2003
    The invalid things are:
    1. Rep. Path variable only get the value 01.2003. The impact the KF is only restricted by 01.2003.
    It supposed to be restricted by 01.2003, 02.2003, 03.2003, 04.2003.05.2003.
    The questions are:
    1. How can i overcome this problem?
    2. How should i do, if i want to use replacement path in restricted KF that can restrict by 01.2003, 02..2003, 03.2003, 04.2003, 05.2003 ???
    Could you help me to suggest what i should do please .. ?
    Really need your guidances....
    Regards,
    Niel.

    Hi Niel,
    When you use a variable(v1) of processing type replacement path and try to replace it wih another variable the replacement is only by single value. This you can find by details tab in the variable(v1) being created.
    Hence you have only options of replacing it wih from value/ to value/ difference.
    I didn't undersand why you wish to use variable(v1) wih processing type replacement path when you could have used the input variable type for restriction of the characteristic in the restricted key figure.
    I think for your requirement variable processing by manual input is more suitable unless you have some reason for replacement which I didn't undestand.
    Thanks and regards,
    Sunmit.

  • HT201272 You seems not to understand what I mean and what I'm having like problem. I still have my payment recut  from October of this year when I bought 9 songs in the iTunes Store from my iPhone 4S. The problem is from all the 9 songs, 7 are still avail

    You seems not to understand what I mean and what I'm having like problem. I still have my payment receipt  from October of this year when I bought 9 songs in the iTunes Store from my iPhone 4S. The problem is from all the 9 songs I've paid for, only 7 are still available from this list on my iPhone. There is no possibility to download the other 2 without paying for them. I've spoke to the lady from Mississippi on the phone 2 days ago from about 2 hours calling from Belgium but unfortunately she couldn't help me. It's the 3rd time I complain about this. How many time shall I pay for the same songs?? If you can access my music list and my past receipts payment you will be able to find out what I mean. I went back on iTunes I've found the the songs I already downloaded in October that should be on my playlist but if I click on them it will charge me again 0,99 cents. It's been 3 years I've been using the same apple ID with my iPhones. I just wand to get my songs back without having to pay them twice or 3 times

    1. iTunes won't offer cloud downloads for songs that it "thinks" are in your library, even if it "knows" the files are missing. If you've exhaustively searched for the missing files and there is no prospect of repair by restoring to them to their original locations, or connecting to new ones, then delete that tracks that display both the missing exclamation mark and are of media kind Purchased/Protected AAC audio file. Don't hide from iTunes in the cloud when asked, close iTunes, then reopen. You can download from the cloud links or iTunes Store > Quicklinks > Purchased > Music > Not on this computer > All songs > Download all.
    2. Why? Not sure, perhaps 3rd party tools or accidental key presses combined with previously hidden warning messages when trying to organize the library. There is a hint that using the feature to downsample media as it is synced to a device may also be involved, though I've not replicated it. Whatever the reason a backup would protect your media.
    tt2

  • Hey sur. my name anas and am from morocco i've just got a new iMac 2011 with OSX 10.7 and i want to downgrade to 10.6 please could you help sur to solve this it

    hey sur. my name anas and am from morocco i've just got a new iMac 2011 with OSX 10.7 and i want to downgrade to 10.6 please could you help sur to solve this it

    anas guellaf wrote:
    it still make 3 bips before starting the IMAC.
    That is another problem not related to the Mac OS X version you are trying to use.
    Three beeps at startup means you have a bad ram module in the computer.  Did you install the ram or did it come from another owner this way?  The first problem you need to solve is the bad ram.
    When the iMac starts, go to the apple left side of the menu bar, About This Mac, More Info, System Report, Hardware, Memory and see what the report is on the memory...does the iMac report all memory modules that have been installed as OK or does it show bad memory?  If there is not any information, you then need to remove the memory modules and restart one at a time to see which is bad.
    On the bottom of the screen there should be a small door that you can remove with a small screw driver.  You need to lay the iMac flat, disconnect the power cord, remove that small door and remove the memory modules.  You can then put two in (if it has four) and see if it starts without the beeps.  Do that with each module so you find out which is bad.  Once you know the bad memory, you can buy a new module, just like the ones installed, so the iMac starts without the beeps.
    Next, you cannot use a DVD for another computer for your iMac unless it is from one that is identical to yours.  So, you need to talk to Apple and have them send the DVD for your particular iMac.

  • TS1453 Hi, I bought Apple tv traying to rent a movie but there problem with itunes, and there is on apple tv don't have my country. could you help me please how can I solve this problem?

    Hi, I bought Apple tv traying to rent a movie but there problem with itunes, and there is on apple tv don't have my country. could you help me please how can I solve this problem?

    Whinston,
    I live in Azerbaijan. Recently I bought apple tv in New York. When I come back to my country tried to rent movies from my country but couldn't find my country name on apple tv menu, so there is a problem I don't know how to fix it. is there have another way to take a rent movies?

  • Right now I changed my ID but when I am trying to update my apps only see this message " Your Apple ID is been desactivated". Could you help me

    Right now I changed my Apple ID but when I am trying to update my apps only see this message " Your Apple ID is been desactivated".
    Could you help me

    This may help:
    http://support.apple.com/kb/ts2446

  • TS3716 My relatively new ipod touch 16 gb either does not show up as a drive or everytime says it does not recognize my ipod when connected to add music.  I didn't have problems loading music originally, but this is a new occurrence.  Could you help?

    My relatively new ipod touch 16 gb either does not show up as a drive or everytime says it does not recognize my ipod when connected to add music.  I didn't have problems loading music originally, but this is a new occurrence.  Could you help?

    Hey, Thanks a lot.  It took quite a bit of time to resurrect this ipod.  I tried the upgrade again, but still would not recognize my ipod. So I went to the next step and reset my ipod, wiping of all of the information like it was new.  This helped my laptop see the ipod on itunes, but did not sync. So, I deleted the itunes off my computer completely, restarted and then reinstalled the newest itunes, and then restarted.  Finally, it recognized my ipod and started to download each song.  It took awhile as there was 602 songs, but finally it works.  Yea!!!  I never had any problem with my old nano, but this touch has been another animal for sure. Thank you again and also the community for information.  This was a helpful forum and will recommend to others if they get stuck with their ipod or iphone.  Take care, Karen

  • HT4623 I installed the new IOS 7 and now it asks me to inform a password, but I really do not know what password I need to inform. Could you help me:

    I installed the new IOS 7 and now it asks me to inform a password, but I really do not know what password I need to inform. Could you help me:

    if you mean it asks you to add a passcode to the device, you may say no.  It really tries to encourage you to put a code on, by asking twice.....

  • Dear Apple Rep,  I have recently transferred purchases I've made on my iPad to my PC.  But the album artwork, while correct on my PC, is all messed up on my iPad--wrong artwork on the many of the albums.    Could you help me in resolving this annoying pr

    Dear Apple Community,
    I have recently transferred purchases I've made on my iPad to my PC.  But the album artwork, while correct on my PC, is all messed up on my iPad--wrong artwork on the many of the albums.  
    Could you help me in resolving this annoying problem?
    Thank you in advance for your assistance,
    Jonathan Treat

    Removed; inapplicable due to date of thread.
    Message was edited by: Dave Sawyer

  • Could anyone explain me what this statements means??Thanks

    Hi,
    I just reading an ABAP program, found below statement and i am not understand about it...Could you help me?  Thanks!!!
    it_file-ztext+18(5)  to  it_inbound_file-box_nbr
    As it_file-ztext is an uploaded text file, i am confusing on the '18(5)'...what does this means??
    Is it means that only extract the character which started from position18 and the Length is 5?? IS it???
    Thanks!!

    Hi
    Yes, You are right
    it is field offsetting
    it will take just 5 characters starting from 18
    example.
    str = 'abcdefgh'.
    str+4(2)  = ef.
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • I get message:can't save library file not enough access privileges.Don't understand what this means?

    I get message:"Can't save library file.  Not enough access privileges" .Don't understand what this means. No visible effect that I can see now.

    Classic example of why you should save your workm in progress...just hit Ctrl+s to do it on the fly.
    Yes I know. But it is the first time I work with Photoshop on such a big project and I thought it would be more stable.. Do the newer versions manage the memory better ?
    You can shrink your image down which will make it smaller enough to save
    Not enough memory to resize the image. And in the manipulation, it would corrupt some of my layers..
    you can try to save as a diffeent format
    I could succesfully save in Bitmap format. But I lose all my layers info..
    The making loads of screen shots would be good if it wasnt really an
    option seeing as it would use even more memory to do that then put the
    image together out of the screen shots.
    I made screen shots without any problem. I saved them through MS Paint without any memory problem, while Photoshop in parallel was just used as a static image for snapping...

Maybe you are looking for

  • MY VERIZON MOBILE

    You would think that VERIZON would make sure that THEIR new 4G Thunderbolt would support all their  VERIZON APPS!!!!!!!! This app is a very convenient way to pay the bill. Please fix this Verizon.

  • Missing shared libraries?

    Hi all, I tried to install j2ee 1.4.2 Beta on my redhat linux 9 machine. After I downloaded and unzipped the zip file, I follow the installation instruction by typing ./setup in the extract folder. However, the follow error comes out: error while loa

  • OracleParameter and IN Clause

    I have a parameterized Select query in which I want to use a parameter in the IN clause. There will be multiple ID's determined at run-time and I'd like to receive all matching records with one call. SELECT * FROM TABLENAME WHERE MYID IN (:p_Paramete

  • My 3gs (11 months old) has been losing all signal

    my 3gs (11 months old) has been losing all signal for calls and both 3g/wifi, goes to "searching" then "no signal", and back to some signal but not for long at all. i upgraded to ios5 couple of wks ago but this was all happening before that, was hopi

  • Installing Solaris 10 with 19" DELL Flatpanel

    Hi! I installed the Solaris 10 (10/06) with an NVidia 6600 GT using a DELL 19" Flatpanel Monitor. The suggested driver didn't work, so I used the NVidia VESA-driver. The reason was, that the monitor displayed only a message that a unsupported resolut