Will instanceof  work  in this case

I am trying to simplify my code, and here is what i have
i have the below classes :
interface xyz
class A implements xyz
class B implements xyz
i have lot of set/get methos in class A and class B. which are not in xyz.
setfields(Obj) //this obj can be class A or class B
Object ob=null;
if ( obj instanceof A)
ob=(A)obj;
if(obj instanceof B)
ob=(B)obj;
//Here depending on the object i want to use set methods on that particular object. Is it possible?
But when i do this , ob doesn't show the methods in Class A / class B.
Am i doing the correct way.
}

I agree that's a good way to simplify your code, but you had a mistake
in that...
ob=(A)obj; // ob is a instance of Object
because ob is just a object, so it can access only Object's method.
you can correct code like this.
A obj = (A)obj; // obj is a instance of Class A
then, it can access any method in Class A.
and I recommend make a 'int getType()' method in interface and
use that. for example...
interface xyx{
public int getType();
class A implements xyz
public int getType(){return 0;}
class B implements xyz{
public int getType(){return 1;}
setfields(xyz Obj) // this obj is must be instance of class implements xyz
switch(Obj.getType()){
case 0:
A Obj2 = (A)Obj;
break;
case 1:
B Obj2 = (B)Obj;
break;
you can make static int variable or enumeration class for more elegant code.
I'm sorry about I can't explain well so that english isn't my mother tongue. -_-;;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • I've moved my Aperture library to another computer, and masters are referencing an old path name.  How can I update these references?  Reloctating masters does not work in this case :(

    I've moved my Aperture library from one computer to another using Finder.
    I merged the library with one which was already on the computer.
    Now, the photos I imported have reference to the old path name on my old computer.
    How can I update these references as "Relocate Masters" does not work in this case?

    Just one suggestion to be able to reconnect all at once:
    Create a smart album containing the images with missing masters:
    File -> New ->  Smart Album,     and add a rule: File Status is "Missing"     (or File Status is "offline")
    Then select the images in this album and go to the File menu:
    and select:   File -> Locate referenced File
    If you are lucky, Aperture will reconnect all at once, if you point the first image version to its counterpart.

  • I want to upgrade my iMac (late 2006) to Mavericks. It meets all other specifications. Will Mavericks work on this computer?

    I want to upgrade my iMac (late 2006) to Mavericks. It meets all other specifications. Will Mavericks work on this computer?

    No. The newest Mac OS X version compatible with that iMac is 10.7.5.
    (110243)

  • I had a repair done on my MacBook Pro and had to have a new hard drive installed. The Apple Auth Repair Shop then updated the OS from 10.6.8 to 10.7.5. Now my iPhoto v 9.2.3 will not open and it sounds like it will not work with this OS. Can you plea

    I had a repair done on my MacBook Pro and had to have a new hard drive installed. The Apple Auth Repair Shop then updated the OS from 10.6.8 to 10.7.5. Now my iPhoto v 9.2.3 will not open and it sounds like it will not work with this OS. Can you please advise?

    You may need many other updates to retain compatibility with Lion. I suggest you reinstall Snow Leopard. Unfortunately, you will need to erase the drive first. Be sure to backup your data if you haven't done so already.
    Clean Install of Snow Leopard
    Be sure to make a backup first because the following procedure will erase
    the drive and everything on it.
         1. Boot the computer using the Snow Leopard Installer Disc or the Disc 1 that came
             with your computer.  Insert the disc into the optical drive and restart the computer.
             After the chime press and hold down the  "C" key.  Release the key when you see
             a small spinning gear appear below the dark gray Apple logo.
         2. After the installer loads select your language and click on the Continue
             button. When the menu bar appears select Disk Utility from the Utilities menu.
             After DU loads select the hard drive entry from the left side list (mfgr.'s ID and drive
             size.)  Click on the Partition tab in the DU main window.  Set the number of
             partitions to one (1) from the Partitions drop down menu, click on Options button
             and select GUID, click on OK, then set the format type to MacOS Extended
             (Journaled, if supported), then click on the Apply button.
         3. When the formatting has completed quit DU and return to the installer.  Proceed
             with the OS X installation and follow the directions included with the installer.
         4. When the installation has completed your computer will Restart into the Setup
             Assistant. After you finish Setup Assistant will complete the installation after which
             you will be running a fresh install of OS X.  You can now begin the update process
             by opening Software Update and installing all recommended updates to bring your
             installation current.
    Download and install Mac OS X 10.6.8 Update Combo v1.1.

  • Product key will not work with this edition of Windows 7

    I received a product key for Windows 7 Professional N whilst I was at University via Dreamspark. I'm building a new computer and when it's come to inputting the product key, it comes up saying Product key will not work with this edition of Windows 7.
    The version I installed was Windows 7 Professional using an iso and a USB. I rang the phone activation number and when I got through to a representative, I gave him the product key and he said it is valid and should be working. He transferred me to technical
    services but instead I got cut off.
    At this point I'm really not sure what the issue is, the key was for Windows 7 Professional N, I installed Windows 7 Professional and customer support confirmed it as a valid key. Am I missing something?

    Post your issue to the Windows 7 Genuine Issues forum.  Here are the instructions on how to produce a diagnostic:
    MGA
    Diagnostic Report:
    To properly analyze and solve problems with Activation and Validation, we need to see a full copy of the diagnostic report produced by the MGADiag tool (download and save to desktop -http://go.microsoft.com/fwlink/?linkid=52012 )
    Once downloaded, run the tool.
    Click on the Continue button, after a short time, the Continue button will change to a Copy button.
    Click on the Copy button in the tool (ignore any error messages at this point), and then paste (using either r-click/Paste, or Ctrl+V ) into your post.
    One
    Issue Per Thread:
    Most Activation and Validation issues look the same, on the surface, but can have many different causes and fixes. This is why we ask for a diagnostic report and this is also why we ask that you create your own thread for your issue (in other words,
    don't post your issue in another person's thread). 
    It just becomes too complicated to try to troubleshoot multiple different issues in the same thread.
    New
    to the Forums?
    Instructions
    by  Kamin of Ressik 
    Wanikiya and Dyami--Team Zigzag

  • I downloaded Firefox 4 and tried to launch it. The message said that Firefox will not work with this version of Mac OX. Please advise.

    I downloaded Firefox 4 and installed it. When I tried to launch it, a message came up saying that Firefox will not work with this version of Mac OSX. Now I have no Firefox. How can I get Firefox 3.6 back on my Mac? How can I make Firefox 4.0 work? Please advise.

    Thanks for the reply so quickly! Is the tenfourfox going to be be just as safe and as high of quality as the Firefox 4? Also since Mozilla's website says, "Firefox 3.6.x will be maintained with security and stability updates for a short amount of time. All users are strongly encouraged to upgrade to Firefox 4" does that mean if I go back to 3.6 there will be security and stability issues after a "short amount of time"?

  • HT4914 My music is stored on an external hard drive. All music that I buy, whether from itunes or some other provider, automatically gets loaded onto my external drive. There is some music on my computer drive as well. Will match work in this circumstance

    My music is stored on an external hard drive. All music that I buy, whether from itunes or some other provider, automatically gets loaded onto my external drive. There is some music on my computer drive as well. Will match work in this circumstance?

    I followed all the instructions for consolidating my music into one folder on my external hard drive. (I'm struggling with this because my ext HD was renamed when I synched my iPod shuffle last night. The "E:" drive has now become the "F:" drive and all my songs have those dreaded exclamation points next to them. Exploring my computer, I found "My music" folders in two place on my C: drive and one place on my external hard drive... and the song list in each place is different.
    Argh.
    So... following the directions in the article reference here, I attempted to consolidate all of my songs into one folder on my external hard drive.
    But.. I checked the song list when the "consolidation" was complete... and MANY songs are missing. They're still on the C: drive, but don't appear to have been copied to the new folder on the ext HD.
    I would appreciate any suggestions.
    Thanks so much!
    Edit: I tried to reassign the ext. HD a permanent letter, but my Control panel does not appear to offer the option of Administrative tools. Is there an easy way to get to this, as this seems to be the root of the problem?
    Thanks.
    Message was edited by: hbdivegirl

  • I am using OS 10.6.8. Will CC work on this version?

    I am using OS 10.6.8. Will CC work on this version?

    System requirements for Cloud Programs
    -http://www.adobe.com/products/creativecloud/tech-specs.html

  • When will Adobe Muse will integrate responsive design (like bootstrap twitter). Will you work on this or no ?

    When will Adobe Muse will integrate responsive design (like bootstrap twitter). Will you work on this or no ?

    Hi Gaurav,
    Yes, thank you. However I was more specifically referring to this:
    "Sites that use responsive web design, i.e. sites that serve all devices on the same set of URLs, with each URL serving the same HTML to all devices and using just CSS to change how the page is rendered on the device. This is Google’s recommended configuration."
    You can find that on this Official Google Webmaster Central Blog.
    I would think that Adobe might want to open their ears to Google's recommended configuration. No? Isn't it about time that Adobe starts listening to their customer base (and Google)? We've been tirelessly asking for responsive design for years.
    Regarding:  "Adobe Muse works perfectly when it comes to Separate URLs". True ONLY if you can get it to (re)direct correctly. Since they introduced multi device layouts I (and others) have never been able to get the correct version to display on any of my tablets (Archos & Samung Tab 2, 3, 4). The phone site would always show up on the tablet even though the hierarchy for the tablet is: Tablet/Desktop/Phone. Adobe has acknowledged this issue exists and has done nothing to solve it. How again does that help me?

  • How many tempdb mdb files will be created in this case?

    How many tempdb mdb files will be created in this case?
    SQL Server detected 2 sockets with 6 cores per socket and 12 logical processors per socket, 24 total logical processors; using 24 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
    I have sql server 2012 enterprise edition 64 bit
    Thanks

    Its all upto your server usage and number of processors,
    Note : If the number of logical processors is greater than 8, use 8 data files and then if contention continues, increase the number of data files by multiples of 4 (up to the number of logical processors) until the contention is reduced
    to acceptable levels or make changes to the workload/code.
    For optimal performance, you could add data files of the same size to tempdb up
    to the # of processors on your server. So a 4 processor server should have 4
    same-sized physical files for tempdb for optimal tempdb performance. The reason
    you want the files to be the same size is because SQL Server tries to keep the
    files filled to the same proportion. So if you had a 100MB file and a 200MB
    file, SQL Server will try to keep them at the same fill level, for example 50%,
    which means that the 200MB file will be written to approximately twice as much
    as the 100MB file which reduces the performance gained by having multiply
    files.
    Please read this below links just for your reference.
    http://support.microsoft.com/kb/2154845/en-us
    http://blogs.msdn.com/b/sqlserverstorageengine/archive/2009/01/04/managing-tempdb-in-sql-server-tempdb-configuration.aspx
    http://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-1230-tempdb-should-always-have-one-data-file-per-processor-core/
    Raju Rasagounder MSSQL DBA

  • My IPhone 4s is freezing up and the wifi will not work. This happened after the update. I have tried to restore it and that did not fix it. Any suggestions?

    My IPhone 4s is freezing up and the wifi will not work. This happened after the update. I have tried to restore it and that did not fix it. Any suggestions?

    Most of your purchases content can be downloaded again via the Purchased tabs in each of the store. I realize that this will be a problem for the iTunes Store on the iPad, but that has nothing to do with apps, since apps are in the App Store.
    If you backed up synced with iTunes before you restored the iPad, your content should be in iTunes on your Mac and you should be able to sync it back again.

  • Will Tiger Work On This G4?

    Hi guys,
    Will 10.4.11 work on this machine?
    PowerMac G4
    1 CPU
    533 Mhz
    512 Ram
    133 Bus
    I just need the G4 to do email and web surfing.
    Any problem?
    Thanks!

    I think there's something more wrong with the G4 if it's crashing.
    I did try that, and it crashes the mac (G5 iMac) I'm trying to install from. Or, to be more precise, setting up the target mode works ok, but trying to install over it crashes the installing mac.
    Just to clarify, you're installing using the G4, correct? But the iMac is in t mode? Which one is crashing?
    Could I possibly turn that empty volume in to an OSX installer, and connect it to the G4?
    Yes, you can if it's a Firewire Drive, not if a USB only drive though, use Disk Utility to "Restore the Install Disc to the HD that's empty.

  • I bought Keurig K cups from BB and my machine says "oops these cups will not work in this machine"

    ok so I saw a wonderful deal by Best Buy to get K cups on sale so ordered the amount to get free shipping but when I tried to use them I get a error message on my machine and they will not work in it. I have the newest keurig and wanted to use it for the peach flavored ice tea. I know that BB will not take them back because they are opened. I never saw one thing on the website where it would not work in the Keurig 2.0. Is there any recourse for me? Why is there not something mentioned in the ad that says which ones they will work in? I have no idea what ones of the order will work and if I open them all I cannot return any of them. Can anyone offer any advice?

    Hello gmaof3,
    The Keurig 2.0 looks pretty fantastic! As I understand it, Keurig made some changes to what pods will work in the Keurig 2.0. To ensure you have the correct pods that will work in your brewer check for these identifiers:
    ·         K-Cup pods  with Keurig 2.0 Brewing Technology feature a white, gray, or lavender outer ring
    ·         K-Carafe pods with Keurig 2.0 Brewing Technology feature a green dot
    If you happen to have received K-Cups that don’t have the Keurig 2.0 Brewing Technology, please feel welcome to visit your local Best Buy to see what options we may have for you under our Return & Exchange Promise. Alternatively, you may also contact Keurig regarding this at 1-866-901-2739. If you should have any questions, please let us know!
    Regards, 
    Tasha|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Will FCP work on this machine?

    I'm thinking to buy an Apple Mac mini MB139LL/A and I need to install FCP Studio 3 to that comp.
    Will it work with those machine? Or I have to buy something more better?
    Message was edited by: WWarrior

    Thank you David S. for your answer.
    I always use my Mac Pro 8 Core @ home to correct in Color so for me it won't be too big problem.
    I live in Russia and you can see that I've got some problems with English. Can you explain the word "iffy"? Will Motion be slow?
    I'm interested just to make a raw cut and to learn Motion with that MacMini.
    Thank you!

  • I have recently switched ISPs and have anew e-mail address but ThunderBird will not work with this address. Have tried tech staff with Bell to no avail

    My old e-mail address was SHAW XXXXX.and worked very well with Thunder Bird mail. I recently switched to new ISP Bell and my new address is XXXXXX However with several attempts with techs ,Thunder Bird will not work with my new ISP. I had to start using Outlook.com and Outlook Express 6 for e-mail,but I really liked Thunder Bird and have numerous e-mails stored in it that I cannot import.
    Outlook Express 6 is outdated and because I am running Windows XP it will not give me a newer version.I find Outlook.com confusing to me. Can you help

    Why don't you tell us what you did and why it didn't work? Start from File/New/Existing Mail Account, enter your details, click Continue, then immediately click Manual config. On the next screen enter these settings:
    incoming POP server: pophm.sympatico.ca
    port: 995
    Connection security: SSL/TLS
    Authentication: Normal password
    User name: your full email address
    outgoing SMTP server: smtphm.sympatico.ca
    port: 587 (or try 25)
    Connection security: STARTTLS
    Authentication: Normal password
    User name: your full email address
    http://support.bell.ca/Internet/Email/How-to-use-Bell-Mail?step=3
    Also, enable POP access as mentioned in the link.

Maybe you are looking for