!instanceof - how can i get this logic to work...because it doesnt

So I'm working with S Linked Lists and theres an add(E object) method that we are creating.
So its supposed to first check-well at least at some point in the method- that the object being passed in is of the same type as my SLL. If its not im supposed to throw a new ClassCastException.
I tried this at the beginning of the method:
public void add(E obj) throws ClassCastException
         if(obj !instanceof Doctor) throw new ClassCastException();
         Doctor d = (Doctor)obj;
         int index = 0;
         MySLLNode<E> item = head;
         for(int i = 0; i<size(); i++) {
              if (d.compareTo(item.getData()) < 0) {
                   super.add(index,obj);
                   size++;
                   break;
              if (d.compareTo(item.getData()) == 0) {
                   super.add(index+1,obj);
                   size++;
                   break;
              else {
                   index++;
                   item = item.next;
         addLast(obj);
         size++;
    }.....but im getting a couple of errors
./MySortedSLL.java:42: ')' expected
         if(obj !instanceof Doctor) throw new ClassCastException();
               ^
./MySortedSLL.java:42: illegal start of expression
         if(obj !instanceof Doctor) throw new ClassCastException();
                 ^
./MySortedSLL.java:42: ';' expected
         if(obj !instanceof Doctor) throw new ClassCastException();
                                  ^So is there a better way to check that the object being passed in (which wants to be added to my SLL) is of compatable type...being that it is of type Doctor?
Thanks in advance....

Rather than
      if (f !instanceof Fubar) {
         System.out.println("Yeah!");
      }try
      if (!(f instanceof Fubar)) {
         System.out.println("Rah!");
      }

Similar Messages

  • My "Hanging with Friends" app keeps crashing whenever I try to open it. I have deleted and re-downloaded the app, restarted my iPhone, and even restored my iPhone all together, and nothing is working. How can I get this app to work again?

    My "Hanging with Friends" app keeps crashing whenever I try to open it. I have deleted and re-downloaded the app, restarted my iPhone, and even restored my iPhone all together, and nothing is working. How can I get this app to work again?

    Can you start Firefox in [[Safe mode]] ?
    You can also do a clean reinstall and download a fresh Firefox copy from http://www.mozilla.com/firefox/all.html and save the file to the desktop.
    Uninstall your current Firefox version and remove the Firefox program folder before installing that copy of the Firefox installer.
    It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    You can initially skip the step to create a new profile, that may not necessary for this issue.
    See http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Clean_reinstall

  • How can I get this thing to work without apple id? :(

    I've got Iphone 4s from my boss instead of my paycheck due to a bankrot. And he doesn't remember his apple id,password or e mail he used to activate Iphone.. How can I get this thing to work without it? :/

    You can't.
    Sounds like it he gave you a stolen iPhone or at least a worthless one.

  • How can I get this program to work -- Adobe Send or Adobe SendNow

    How can I get this program to work?  I have used Adobe SendNow successfully for several years and am on automatic renewal and getting nothing but frustration for my money!  I have been unsuccessful at sending anything in the past several months.  Today while working on a deadline and many unsuccessful attempts to upload files, I signed up for a free trial at a competitor in order to get my files sent.  Want a refund  -- or better yet, keep my money and get it to work right again.

    You can't.
    Sounds like it he gave you a stolen iPhone or at least a worthless one.

  • How can i get the ipad to work because my little brother put a password on it and it now is blocked and cant get into it ???

    how can i get my ipad to work because ,y little brother put a password and cant get into it ???

    You must restore the iPad with iTunes.

  • How can I get this JApplet to work?

    Okay, so I have a website now...
    it is called www.nothingbutinfo.info.
    I would like to put a japplet onto a page... because HTML is annoying and I know 1000000 times more about java.
    So... this is the code I have been able to find...
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled</title>
    </head>
    <body bgcolor="#ffffff">
    <div style="z-index: 4000; position: absolute; margin: 1px; width: 0px; height: 0px; top: 0px; left: 0px" id="html0" name="html0">
    <applet codebase="Applets" code="TestApplet.class" width="400" height="300">
    <param name="_cx" value="26" />
    <param name="_cy" value="26" />
    Sorry, no dice ... this requires a Java-enabled browser.</applet> </div></body>
    </html>Towards the end is the applet part.
    It does not work.
    This is where I have my files stored..
    www.nothingbutinfo.info/public_html/Applets/
    ...TestApplet.class,TestApplet.java,TestApplet$1.class,TestApplet$2.class
    What more do I need to do to get this started?
    Any help will be greatly appreciated.
    PS I looked at the tutorials, that is how I got here. Going there again won't do much.

    AwakenToThePain wrote:
    After that, what you wrote turned out to work.Glad you got the first applet problem sorted. I offer a tool for testing applets, Appleteer, for when your next applet problem crops up in (wait.. checks watch..) just a while.
    That 'first applet' and (bracketed) part is my way of saying "applet deployment is a PITA".
    I highly recommend you put the classes in a Jar and deploy the app. using [Java Web Start|http://java.sun.com/javase/technologies/desktop/javawebstart/index.jsp]. I also provide JaNeLA, for checking JWS based app. launches. ;-)
    Your comment about what Netbeans forces, amused me. I am running Ubuntu as my OS and when I recently changed over (from Win.) I tried to like Netbeans again - after having previously spurned it. I write a lot of SSCCEs, and the Shortest way to write them is to leave out a package statement. Since I could not see a way to get around NB insistence on packages (which is probably a good thing, in the long run), and was too lazy to remember to remove the package statement before posting examples, I put NB aside again, ..and added some Tools to the generic Ubuntu text editor (Gedit) to compile, run applets, and invoke Ant on build files.
    Don't get me wrong. IDEs like Netbeans, Eclipse, JCreator and the like are fine tools and make some things very easy (refactoring code, drag'n'drop GUI development..), but to do that well, they require that the programmer understands both the (Java) code being churned out, and the intricacies of the IDE. What IDEs offer is not something I need often enough, to bother dealing with their intricacies.

  • How can I get this query to work?

    HI
    SELECT  TOP 200  [word] ,COUNT(word) AS count
              FROM [COMMENT_WORDS]
              where word NOT in (SELECT wordText FROM word)
                GROUP BY word
                ORDER BY COUNT desc
    gives me this error:
    Msg 468, Level 16, State 9, Line 1
    Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.
    please help

    Thanks I changed the count name but I am still getting
    Msg 468, Level 16, State 9, Line 1
    Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.
    I also went into the word database and ran
        ALTER DATABASE [word] COLLATE
        Latin1_General_CI_AS
    and now both databases have the same colaltion but I still get the error:
    Msg 468, Level 16, State 9, Line 1
    Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.
    I am using ms sql 2005

  • TS1702 My cars 2 app mate app is not working after upgrading from ipad to ipad 2...... synced.... uninstalled and re installed several times as well as wiped ne ipad out and re did the whole proccess several times. how can I get this app working?

    I have installed the cars 2 app mate on a ipad 2 from an ipad 1 synced with itunes account.. all is working except this app. After many times of un installing and re installing aswell as talking to apple tech suport this app is still not working.... its there it just has no function...... how can i get this installed and working, my grandson is autistic and uses this app many hours a day........ it is important for me to get this up and running again for him.......

    (1) So, I found a youtube video showing how to open up my iMac and replace a Disk drive. I opened it. I removed the disk drive. I opened the metal cover of the lid of the disk drive. It was clean and immaculate; so, it destroyed and debunked the dirty drive theory. But, just to make sure I sucked around the optical sensor with a vacuum and gently brushed it with a Q-tip.
    (2) I then watched a you tube video showing how the drive operated (it was a drive supplied with power outside an iMac with a transparent cover unlike the opaque metal cover that we have on our drives). My scientific curiosity started to wonder if somehow the mechanical part (of the electro-mechanical assembly) was locked or jammed. So, I started messing with the arms with the utmost care after watching the video to see if i could move them manually. Yes on some. The main arm that is linked with the drive motor was immovable. The rest I played with a little bit, took great notice in the start of the video to see how the arms looked before inserting a disk. I then put it all back together.
    It works now. My guess is that taking it out and then placing it back in along with the resetting options that others have done was the trick. I believe it is a possibility that the hard drive became locked mechanically in some strange manner after ejecting a DVD in conjunction with the uploading of the new OS. I believe the actual removal, reinstallation, and resetting of the drive put everything back into sync. My computer sits in a climate controlled dust free environment. I knew for a fact that this hard drive was OKAY.

  • Adobe CR 6.7 does not install into CS5, how can I get this installed to view CR files?

    Just installed CS5 onto new computer. Adobe bridge and CS5 do not recognize CR format. How can I get this installed. I have tried up dating and downloading the CR6.7 update, but can not get it to install. What do I do?

    Product updates

  • Hello, I want to restore a backup on my Iphone 4S, but in i-tunes it's not vissable. When I'll look on te pc: (username)\Application Data\Apple Computer\MobileSync\Backup\ it's there! How can I get this backup to my iphone or itunes? Thanks in advance!

    Hello, I want to restore a backup from this afternoobut in i-tunes it is not visseble. When I'll look on te pc: (username)\Application Data\Apple Computer\MobileSync\Backup\ it's there! How can I get this backup to my iphone or itunes? Thanks in advance!

    Follow the steps in this article to restore from iTunes back up:
    http://support.apple.com/kb/HT1766
    Since you say you cant see the back up in iTunes you should be able to see it when following the last step where it says for iTunes 10.7 or earlier. Dont worry as this step also works for iTunes 11.

  • I have an Retina display MacBook Pro with HMDI out port. I also have an HDMI to Component cable with Audio Plugs. How can I get HDMI out to work with this cable when plugged into the Component and Audio ports on my TV?

    I have an Retina display MacBook Pro with HMDI out port. I also have an HDMI to Component cable with Audio Plugs. How can I get HDMI out to work with this cable when plugged into the MacBook Pro and connected to the TVs Component and Audio in ports.

    Will not work.  To my knowledge, dual converting like that isn't supported.  The Mac must detect the connected video output device and that sort of info cannot be done across an analog component uni-directional connection.

  • My iPod Classic is seen by Windows but not by iTunes.  I have reset it, gone to disk mode and it won't show up in iTunes.  There appears to be music on it in a file called MUSICSAVE.  How can I get this to work with iTunes again?

    My iPod Classic is seen by Windows but not by iTunes.  I have reset it, gone to disk mode and it won't show up in iTunes.  There appears to be music on it in a file called MUSICSAVE.  How can I get this to work with iTunes again?

    1. Update iTunes to the latest version. Plug in your iPod. If iTunes still can't recognize it, then in iTunes in the top left corner click help> run diagnostics. On the box that comes up, check the last two things. Click next and it should identify your iPod.
    2. Click on your windows start menu. Type in "services". Click on it and when it pops up, on the bottom of it click on "standard". Now Scroll down to find "Apple Mobile Device" Right click it when you see it and click on "Start". When it has started, close iTunes and replug in your iPod and it should show up.
    3. Check the USB cable
    4 Verify that Apple Mobile Device Support is installed
    5. Restart the Apple Mobile Device Service and verify that the Apple Mobile Device USB Driver is installed.
    6. If you just want to add some photos, songs and movies from computer to your devices, you can use an iTunes alternative to do the job
    7. Check for third-party software conflicts.
    <Link Edited By Host>

  • HT4798 i created my apple id account, verified but know i m unable to log on, it says incorrect password, i tried to reset via forgot password option but it does not send reset password page to my e- mail address, how can i get this sorted or delete my pr

    User created apple id account, verified but know she is unable to log on, it says incorrect password, she tried to reset via forgot password option but it does not send reset password page to here e- mail address, how can i get this sorted? or how can i get her whole apple account deleted and created new one using same e - mail address?

    The idea to jumpstart by change was not the smartest one, but gives you an opportunity to use that "temporary" account as permanent. You do not have a choice cause obviously despite you thinking that old account is no more -it does exist on Apple servers. And if you are unwilling to share your [email protected] with friend, just create one extra [email protected] for your friend. One suggestion - do not use gmail.

  • When I am home, calls to my iPhone 5 also go to my other family members' iPhones.  How can I get this to stop happening?

    When I am home, calls to my iPhone 5 also go to my other family members' iPhones.  How  can I get this to stop happening?

    Or better yet, create and use new Apple IDs for others in your household. You could always use different Apple IDs for iCloud services (like iMessage and FaceTime) and iTunes and App Store., but it's even easier to share purchased content now with Family Sharing.

  • I bought 3 iPhone 4s and each should have 5gb of cloud. I want to only use my one iTunes ID. How can I get this storage space increased to the 15 GB?

    I bought 3 iPhone 4s and each should have 5gb of cloud. I want to only use my one iTunes ID. How can I get this storage space increased to the 15 GB?

    iCloud storage is not allocated by device. iCloud storage is allocated to your iCloud AppleID. You get 5GB of iCloud storage.

Maybe you are looking for

  • Error while deploying Web Dynpro Demo Kit

    Hi experts, I tried to deploy the SCAs in the NWDS. The problem is that I can´t deploy the "HM-WDUIDMKTCNT.sca". Do someone know why? I get this error notification: S U M M A R Y: Failed deployments:1 ASJ.dpl_dc.001085 An error occurred while deployi

  • File Associations in 2012 R2 RDS Server using Roaming Profiles

    Background Information We recently moved from using 2008 R2 RDS servers to 2012 R2 RDS Servers. All of our users have roaming profiles. When we migrated from the old terminal servers to the new terminal servers, the users got completely new profile

  • Pagination in custom reports

    Hi, I have formatted my report using PL/SQL with htp.p. Hence the layout is derived from my SQL . I am unable to use the available pagination schemes even if I mention them at the report level. Is there any way I could use them ? If not , do I need t

  • Fixed assets depreciation run

    Hello experts When we run the depreciation the amount is not even and based on the number of days in a month... For example the month of 31 days depreciation is higher thatn a month with 30 days... It seems that there should be a set up where we can

  • Droid Update - contacts have disappeared

    When I installed the new update this morning, my contacts disappeared. Only their mobile numbers appear. So, I have to remember what person had which number and re-create the contact. Also, my text messages all show with the numbers, and not the cont