Instanceof operator, please help!

I am reading the codes written by others. I am confused on instanceof operator here.
(A instanceof B) where A and B are interfaces. I found a definition in a book such that the
instanceof operator returns true or false based on whether the object is an instance of the named
class or any of that class's subclass. However, I didn't find the relationship between A and B is
established in the codes. In this case, I wonder if instanceof operator can still be used because I am thinking that it will always evaluate to be false.
Thank you for your help!
Cathy

The instanceof operator can always be used - a return value of false is still a valid return value!
However, when it comes to interfaces it is possible for a class to implement both interfaces even though there may be no direct relationship between those interfaces.
Have a look at this:
public interface MyInterface
public interface YourInterface
public class MyClass implements MyInterface, YourInterface
}There is no relationship between the two interfaces but I can still do this:
public void check(MyInterface myObj)
  if(obj instanceof YourInterface)
    YourInterface yourObj = (YourInterface)myObj;
    System.out.println("Woo hoo - an instance of MyInterface that's also an instance of YourInterface!");
}Essentially the instanceof operator is asking if the value passed can be cast to something else for the method to use it more specifically.
There could be classes other than MyClass that implement both interfaces, particularly if a system is designed to be flexible.
I hope this makes sense!

Similar Messages

  • The name of the sim is not relevant to the operator please help

    the name of the sim is not relevant to the operator please help...

    I don't understand.  Do you mean that the SIM card is being recognized as 'Wireless Carrier A', but you're actually trying to use 'Wireless Carrier B'?
    Where did you get the SIM card from?  What carrier is it supposed to be?  What carrier is the device saying it is?

  • Order confirmation control - Urgent Please help

    Dear all hi,
    I have 4 opeartions in an order, i want the system to restrict the operations confirmations by NOT allowing to record the preceeding operation timings again to a succeeding operation. but sytem is allowing to record the entries in the following way.... which is wrong for my client's requirement & this is a std sequence.
    Ex oprn 0010
    date 24/01/20008
    Start time : 08:00:00 hrs
    end time   : 17:30:00 hrs
    No problem with this oprn.,
    Ex oprn 0020
    date 25/01/20008
    Start time : 08:00:00 hrs
    end time   : 12:30:00 hrs
    No problem with this oprn.,
    Ex oprn 0030
    date 25/01/20008
    Start time : 08:00:00 hrs
    end time   : 17:30:00 hrs
    Here date & time are repeated from 1st oprn.,
    Ex oprn 0040
    date 24/01/20008
    Start time : 08:00:00 hrs
    end time   : 17:30:00 hrs
    Here date & time are repeated from 4th oprn.,
    in the above example there is repeation of date & time for different operations, but the system is allowing to make such entries.
    How to make it error when the date & time are being repeated for different operations, please help & thanks in advance.
    Edited by: Shaiz on Jan 25, 2008 9:17 AM

    Hi Shaiz,
    Double click on operation number, it will take you to the detailed screen, where you set the releation between operations. So once you set NO OVERLAPPING in routing, the production order operation time will never be same.
    But standard SAP can only control your Operation Sequence in confirmation but NOT the OVERLAPPING TIME ( Which is your specific reqmt)
    So only option to achieve the time sequencing in confirmation is by user exit while conirmation. OR give a thought in using the milestone confirmation, it may resolve to some extent your reqmt.
    Reg
    Ravi

  • HELP!!!! My Hotmail no longer works with Safari v. 5.0.6 and my Imac Leopard operating system 10.5.8.  Please help me with any suggestions on what to do.  Thank you.

    HELP!!!! My Hotmail no longer works with Safari v. 5.0.6 and my Imac Leopard operating system 10.5.8.  Please help me with any suggestions on what to do.  Thank you.  I cannot find any new downloads for Safari that work with Leopard.  The newest ones only work with Lion.  My Firefox browser still works though but I would rather use Safari and cannot access any e-mails or send any e-mails via Safari.  This happened about 3 weeks ago and I thought it was just a glitch on Hotmail's site.  Now I realize Hotmail must have released an update that no longer works with Leopard 10.5.8.  PLEASE HELP ME!!!!  Thanks to anyone and everyone who reads this and attempts to help me.  I do not know what to do....

    Hi Sue,
    What exactly happens when trying Safari?
    They did change it to Outlook recently, but while not pretty, I can access mine with Safari 4.0 still...
    You can also set it up in Mail so you don't need a browser at all if you want.

  • I keep on getting this error when i try to copy files to my 2T Time Capsule, Please help im running out of space on my MacBook Pro.... The operation can't be completed because an unexpected error occurred (error code -50)

    I keep on getting this error when i try to copy files to my 2T Time Capsule, Please help im running out of space on my MacBook Pro....
    The operation can’t be completed because an unexpected error occurred (error code -50)

    I would get an external drive today and copy all your stuff off the TC.. forget trying to load more onto it. There is a good chance after 3years (A 2TB should be only about 2years tops), the disk or the TC itself is on the way out. Do it immediately. If TM is also failing to backup you need to recognise symtoms of impending doom.
    Unfortunately the error messages are archane and it is hard to discover their meaning.
    You also cannot verify a network drive.. you can verify the TM sparsebundle though so do that.
    A5. http://pondini.org/TM/Troubleshooting.html
    Reboot the whole network from off.. certainly if you run later OS it can simply lose the drive..
    If you still fail to be able to copy to the TC.. then get that external and copy off it. Tell us if you can do that.

  • Multiple database operations in Database Adapter - please help

    Hi,
    I would like to have multiple operation in my database adapter. I drop the database adapter onto the composite.xml and follow the wizard. An adapter with one operation is created.
    When I click the "Edit" button on it and run the wizard again, all the previous changes are lost, and only the new operation is present.
    In the "Oracle® Fusion Middleware User's Guide for Technology Adapters 11g Release 1 (11.1.1.5.0) 9 Oracle JCA Adapter for Database" I read the following:+
    While at run time you have Oracle Database Adapter instances, at design time you have the Adapter Configuration Wizard (link). You can run it once to generate a single adapter service end point, and then multiple times in edit mode to make incremental changes to each. It generates all the adapter related artifacts needed when deploying a SOA composite as Table 9-1 lists.
    But I how do I change the Jdeveloper into the "edit mode" ??? I've been trying for hours, and I cant figure it out. Please help!!!

    Hi Vijay,
    did you actually test this? When I finish creating a DBAdapter, there is a operation present. Then when I click edit again on the DBAdapter, and I create another select, when I finish only the first operation is gone, and I can only see the one I've created via the last edit.
    I dont understand your reply. Can I have two operations, each one with select underneath, in the same adapter?
    Edited by: user13604541 on Jan 30, 2012 11:19 AM

  • Please help i can't share my project I did try in all of them and it doesnt work it apears like that........ The share operation Master File has failed The operation could not be completed because an error occurred when creating frame 608 (error -1). and

    I did try in all of them and it doesnt work it apears like that........
    The share operation Master File has failed
    The operation could not be completed because an error occurred when creating frame 608 (error -1).
    and i dont know what to do plese hlp me....
    Re: when i try to share my project to quicktime aroun 50% appears error -1 and i can't share it what to do please help 

    Double post…

  • I am a macbook pro user form last 2 yrs, recently i upgraded to Mountain Lion from Snow leopard. Since then  operational  speed is a major concern. Now It has crashed so very badly that I am scared of my data.Please help me.

    I am a macbook pro user form last 2 yrs, recently i upgraded to Mountain Lion from Snow leopard. Since then  operational  speed is a major concern. Now It has crashed so very badly that I am scared of my data.Please help me.

    Reinstalling Lion/Mountain Lion Without Erasing the Drive
    Boot to the Recovery HD: Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair the Hard Drive and Permissions: Upon startup select Disk Utility from the main menu. Repair the Hard Drive and Permissions as follows.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu.
    Reinstall Lion/Mountain Lion: Select Reinstall Lion/Mountain Lion and click on the Continue button.
    Note: You will need an active Internet connection. I suggest using Ethernet if possible because it is three times faster than wireless.

  • Please help. Since upgrading the new operating system I cannot manage my music through my car

    Please help. Since upgrading to the new operating system, I cannot play my music on my IPhone 4S. I used to use the USB cable and manage my music that way, now it won't even support the auxiliary cord.

    What happens when you try?
    Have you tried basic troubleshooting from the User's Guide?

  • I have an iPhone 4s. After I updated to the Operating System 7, I cannot open the WiFi. Please help.

    I have an iPhone 4s. After I updated to the Operating System 7, I cannot open the WiFi. Please help.

    Try the suggestions here to see if they resolve your problem:
    http://support.apple.com/kb/ts1559
    If these don't work you may have a hardware problem. Visit an Apple store for an evaluation or contact Apple Support.

  • Executing web service operation with complex input - Please help

    Hi All,
    I am working on invoking a web service through ADF. The request format for the webservice consists of multiple occurance of same element. Below is sample request. here <index> is repeating n number of times.
    <soapenv:envelope>
    <soapenv:Body>
              <ns6:StoreDocumentRequest>
                   <ns6:docFileType>ABC</ns6:docFileType>
                   <ns6:Metadata>
                        <ns6:index>
                             <ns6:indexType>Format_Type</ns6:indexType>
                             <ns6:indexValue>ACROBAT</ns6:indexValue>
                        </ns6:index>
                        <ns6:index>
                             <ns6:indexType>Buyer_No</ns6:indexType>
                             <ns6:indexValue>1234567</ns6:indexValue>
                        </ns6:index>
                        <ns6:index>
                             <ns6:indexType>Document_Type</ns6:indexType>
                             <ns6:indexValue>101A</ns6:indexValue>
                        </ns6:index>
                        <ns6:index>
                             <ns6:indexType>Capture_Location</ns6:indexType>
                             <ns6:indexValue>XYZ</ns6:indexValue>
                        </ns6:index>
                   </ns6:Metadata>
                   <ns6:Content>XXXXXXXXXXXX</ns6:Content>
              </ns6:StoreDocumentRequest>
         </soapenv:Body>
    </soapenv:envelope>
    now I need to populate these values thrugh Operation binding in my managed bean class. I have also dragged these parameters and operation on my jsf page to get hold of those in my managed bean context. I am having following code in my managed bean to set these parameters.
    BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
    OperationBinding storeDocumentBinding = bindings.getOperationBinding("StoreDocument");
    storeDocumentBinding.getParamsMap().put("docFileType", filetype);
    storeDocumentBinding.getParamsMap().put("Content", filecontents);
    storeDocumentBinding.getParamsMap().put("indexType", filecontents);
    storeDocumentBinding.getParamsMap().put("indexValue", filecontents);
    storeDocumentBinding.getParamsMap().put("indexType", filecontents);
    storeDocumentBinding.getParamsMap().put("indexValue", filecontents);
    storeDocumentBinding.execute();
    Here I am facing some issues:
    1. The operation is not picking values put from ParamMap(). It is taking values as empty (as in my .jspx page form, I have made it hidden though). It takes value from my jspx page form, which is blank.
    2. when I am manually entering values in the .jspx page form, for <indexValue> and <indexType> tags, it is taking only one value (last one) for creating the request.
    3. the storeDocument() function is a SOAP based service. How can I check for SOAP response after operationBinding.execute(). I checked for response after execution, it sends an object as result. How to get a SOAP response from it.
    I need to fetch few values from the SOAP response and display it on screen.
    Please help me out. I am noob in ADF.
    regards,
    Rajan

    Hi Puthanampatti,
    I followed the link and did exactly as mentioned. Here is my code
    public String downloadDocument(FacesContext context, OutputStream out) throws IOException {
    BindingContext bctx = BindingContext.getCurrent();
    BindingContainer bindings = bctx.getCurrentBindingsEntry();
    OperationBinding retrieveDocumentBinding = bindings.getOperationBinding("RetrieveDocument");
    DCIteratorBinding attachmentsIterator = (DCIteratorBinding)bindings.get("AttachmentsIterator");
    String documentId = attachmentsIterator.getCurrentRow().getAttribute("Seq").toString();
    System.out.println(customSoapProvider.getRequest()); // getting null here
    AttributeBinding docFileTypeVal = (AttributeBinding)bindings.getControlBinding("docId");
    docFileTypeVal.setInputValue(522117);
    Object result = retrieveDocumentBinding.execute();
    System.out.println(customSoapProvider.getResponse()); //getting null here
    but I am getting a null response in the last line.
    what am I missing here.
    regards,
    Rajan
    Edited by: Rajan M on Jan 5, 2013 11:27 AM

  • Illustrator abruptly closed my saved file and said it cannot open the illustration. It says it contains illegal operand. Offending operator: 1. #INF. Can anyone please help?

    Illustrator abruptly closed my saved file and said it cannot open the illustration. It says it contains illegal operand. Offending operator: 1. #INF. Can anyone please help?

    What exactly did it do?
    Crash while saving a file? That most probably ruins a file.
    You can try and create a new Illustrator file, then place the old one in it. If that doesn't work, You might need to search for a backup.
    Don't have a backup?
    Start using the (free) plugin Autosaviour, use Time Machine (or whatever your system offers as a backup software)

  • HT1338 Update bundle just released for Aperture 3.4.2, Safari 6.0.2, and iPhoto 9.4.2 will not install.  Keep getting error "The operation couldn't be completed. (NSURLErrorDomain error -3001.)(102)"  Any one else having this issue?  Please help.

    Update bundle just released for Aperture 3.4.2, Safari 6.0.2, and iPhoto 9.4.2 will not install.  Keep getting error "The operation couldn't be completed. (NSURLErrorDomain error -3001.)(102)"  Any one else having this issue?  Please help.

    Hi there!
    Yes, same problem too; I've already sent an email to apple support and just received a very vague and unpractical response with "call apple support in your country" as main advice. I've obviously emailed back stating that I need a clearer response and I don not have any intention to spend money calling for support when updates is a free tool. I do also believe this is a probem generated on Apple's end, I just wish they learned to say "sorry, it's us;  working on it!"
    Message was edited by: MacLuc

  • My computer keeps saying "The server responded with "502" to operation CalDAVAccountRefreshQueueableOperation." When I use iCal.  Please help.

    Every time I use iCal, my computer says, "The server responded with
    “502”
    to operation CalDAVAccountRefreshQueueableOperation."
    Please help!!

    Same here....didn't see it within the first couple weeks of iCloud, but yesterday it popped up on both my Macbook and iMac.

  • HT1222 I have 10 gb more than what the update requires available and it still prompts that I don't have enough storage please help as I'm operating of of iOS 5 and I'm ready to smash my iPad

    I just purchased more storage and still prompts that I don't have enough storage please help as I'm operating of of iOS 5 and I'm ready to smash my iPad

    Have you tried doing the Update using iTunes on your Computer.?
    See the Using iTunes Section Here...
    How to update your iPhone, iPad, or iPod touch
    Make sure you have the Latest Version of iTunes (v11) Installed on your computer
    iTunes free download from www.itunes.com/download

Maybe you are looking for

  • XviD to DVD using iDVD 2 (or another application?)

    I'd like to be able to download this free movie http://www.starwreck.com/download.php which is in the XviD format, and burn it to a DVD that could play in a DVD player. Is that something I should be able to do, and if so how? Thanks!

  • How I fixed my conection problem

    Here's my setup: Wireless IP (Motorola canopy) The connection comes into the house as ethernet (I'm conected wirelessly to the ISP's router and it's using DHCP That's pluged into an airport express that acts as a bridge to the ISP's router iMac G4 wi

  • Delivery date not getting recalculated while approving via outlook

    Hello, After creating a shopping cart and if we approve after say 3 days via SRM portal the delivery date gets recalculated and takes into reconsideration these days and this is the value that gets populated in the purchase order But if the approval

  • Error - oracle.dss.d4o.administration.D4OConnectionException-D4O-1103 Error

    Hi We have the following configuration installed, 1. Oracle 10G enterprise edition 10.2 2. Application Server Control 10.1.2.0.2 3. Analytic Workspace Manager 10.1.04 The D4OSYS user is unlocked, but still when we try to manage the discoverer catalog

  • Suppressing the message generated by standard SAP code

    Hi experts, I have requirement in which i have to suppress the warning message generated by standard SAP code.Is it possible? If so how? Any pointers will be highly appreciated. Thanks, Rakshith