What's best: "(String) o" or "o.toString()"?

Title sais it all...
What's best: "(String) o" or "o.toString()"?
And why?

It depends what you're trying to do.
If o is known to be a String, but wasn't declared that way, and you need to use it as a String, then (String)o. This way the code expresses your intent. (It also saves you a method call, but that's not the reason you do it.)
If o is an arbitrary object and you want its String representation, then o.toString (or String.valueOf(o) if you need to protected yourself from null).
Don't make the mistake of thinking the two are in any way equivalent. The fact that in certain circumstances they evaluate to the same thing is just coincidence.

Similar Messages

  • What is best practice for conditional rendering?

    i have a set of radio buttons that conditionally render another set, which in turn conditionally render a 3rd set.
    i am doing this by using a valueChangeListener on an h:selectOneRadio
    when i click yes on the 1st set it renders the 2nd set.
    when i click yes on the 2nd set it renders the 3rd set.
    when i click no on the 1st set now it correctly removes the 2nd & 3rd sets, the method also nulls the values.
    when i click yes on the 1st set, it renders the 2nd set with the old values even though they were nulled. and i can see in the debugger they are still null.
    so there seems to be an issue updating the model, but i dont know what that issue is. im sure it just has something to do with the way i am trying this conditional render. please see below for my first field and my valueChangeListener method.
    any help with what is a best practice for this scenario would be greatly appreciated.
    <h:panelGrid id="grid20a" columns="1">
                             <h:outputText value="Does this consult pertain to a specific "/>
                             <h:outputText value="planned or ongoing research project?: *"/>
                        </h:panelGrid>
                        <h:selectOneRadio id="specificResearch1" value="#{ethicsConsultBacking.bean.specificResearch}"
                             layout="lineDirection" required="true"
                             valueChangeListener="#{ethicsConsultBacking.processValueChangeSpecificResearch}">
                                  <f:selectItems value="#{ethicsConsultBacking.yesNoMap}" />
                                  <a4j:support event="onclick" reRender="form"/>
                        </h:selectOneRadio>
                        <h:message for="specificResearch1" styleClass="redText" />
    public void processValueChangeSpecificResearch(ValueChangeEvent e) throws AbortProcessingException
              String newValue = e.getNewValue().toString();
              //reinitialize
              this.setRenderHumanSubjectResearch(false);
              this.setRenderIrbSection(false);
              this.setRenderIrbProtocolNumber(false);
              this.getBean().setHumanSubjectResearch(null);
              this.getBean().setPrimaryIrb(null);
              this.getBean().setIrbStatus(null);
              this.getBean().setIrbProtocolNumber(null);
              //check condition
              if (newValue.equalsIgnoreCase(this.YES))
                   this.setRenderHumanSubjectResearch(true);
               * Clearing validation messages.
               * This will get around the issue with having a field
               * on the form that is both required & immediate.
              Iterator it = this.getFacesContext().getMessages();
              while (it.hasNext())
                   it.next();
                   it.remove();
              this.getFacesContext().renderResponse();          
         }i also tried doing this another way by just using an action method attached to the a4j:support tag, but that introduced a different set of issue. so ill leave that out for now unless that is the direction someone would like to direct my issue in.
    Thanks in advance

    Similar issue is covered and explained here: [http://balusc.blogspot.com/2007/10/populate-child-menus.html]. Not sure if it solves your problem as you're using ajax4jsf whereas I don't, but it might give new insights. To the point you might need to bind the component(s) and use setValue(null) or setSubmittedValue(null).

  • Best string samples for LP X

    Hey all,
    I've been trying to record some string parts with LPX, but I'd like to get something more realistic, especially as far as expression is concerned (like vibrato).
    I saw many different options on the market from people like EastWest, Spitfire, 8dio, etc. Before I go ahead and choose the one that sounds best to my ears, can you guys tell me whether they will all work in LPX?
    Do they need to be compatible with EXS24 or will other formats work too?
    Basically: what are my options?
    Thanks a lot!
    Z
    P.S. If you feel like mentioning what you consider to be the best sounding ones to your ears, I'll gladly check them out!

    The ones you listed are mainly Kontakt Libraires... (The exception being the EW's, that use their own interface/program called Play but frankly I don't care that interface on a Mac... its a bit too buggy for my liking.) so you will need to purchase NI's Kontakt first before you could buy and use those K5 libraries...
    http://www.native-instruments.com/en/products/komplete/samplers/kontakt-5/
    One of the best string libraries that you didn't mention is L.A.S.S...... though I also find the Spitfire libraries to be very good too.... depending on the type of string parts you wish to re-create of course...
    http://audiobro.com
    Again, Kontakt 5 is required to use LASS....
    If cost is no problem then check out the VSL range......which have their own interface/host program...  though I will say even though I love VSL... i still find myself more often than not.. using LASS and Spitfire  as my 'go to' string sounds.. again, depending on the style and sound Im looking for..
    http://www.vsl.co.at/en/211/442/344/314.vsl

  • In iLife08 what is best setting to convert avi 720 and digital video 1080i

    What is the bottom line for best quality for 720 p TV.
    1.) My import is digital video 1080i to i Movie 08 (full quality)
    What should I use for sharing on AppleTV
    - the preset Large (which is 960x 540)
    - or some custom setting 25 fps at 1220x 720? ( H.264 display dimensions at 24/25 fps is 720p (1280x720) ) - or what should the setting be??
    2.) Have Windows avi older 720 *480 video, what is best setting to convert this for Apple TV? The 640 setting on QuickTime premium is not very good
    Thank you so much. Peter

    Your best option if you are using NTSC footage in imovie is the export to/movie large (960 x 540) at 30 fps, the resolution won't go any higher and still work on the tv. Don't even think about changing the framerate to 24/25 fps, even though you'll be able to export to 720p (1280 x720) changing the framerate will make your video jerky.
    If you are using PAL then yes you could export to 720p (even though the specs say 24 fps, 25 fps does in fact work as well), you could try a few tests yourself but I've already done them and IMHO there is so little difference between 960 x 540 and 1280 x 720 that it isn't worth messing about setting up and trying several manual exports to get the best results when you can click one button and be done.
    So far a AVI conversion is concerned, I'd try mpegstreamclip, but saying that I can't really be sure. AVI is a container not a codec and I would need to know what codec is actually used inside the container to answer your question properly (Quicktime may tell you though). The problem with AVI is that it is simply so old (even microsoft abandoned it over 10 years ago), unfortunately in a small number of cases some of the codecs that were used in AVI are simply no longer able to be converted. Probably not so likely but at least you are warned.

  • HT3819 I have 2 Ipod touch's, one a 64gb and one an 8gb.  Whats the best way to use them both on the same itunes account?

    I have 2 Ipod touch's, one a 64gb and one an 8gb.  Whats the best way to use them both on the same itunes account?

    Click here for options.
    (64410)

  • What is Best Way to Handle Things when you dont know Much about them

    The buzz words S/4 HANA is here .. 10 Unanswered questions Best things to know about HANA and list continues but am I  all really ready for this ? The question that circles around me
    What is best to learn and Explore things when you know much about .. S/4 . can some tell me best ay to handle this ? And does knowledge only help to kill the non experience on this ?
    Awaiting reply

    The first thing to do is understand how innovative companies are using S/4HANA. You can do this by watching free broadcasts from SAPPHIRE NOW and the HANA Effect podcast. If you don't understand how the S/4HANA innovations can help, then I think any other learning is just in a vacuum and not going to be productive.
    Then I would suggest taking some of the many free courses available from SAP, like this one from OpenSAP.

  • After recently installing itunes on my new PC running windows 8, the CD/DVD drives no longer works, gives a code 19 message. Seems itunes is impacting the registry of the DVD drive. What is best solution to keep running itunes

    After recently installing itunes on my new PC running windows 8, the CD/DVD drives no longer works, gives a code 19 message. Seems itunes is impacting the registry of the DVD drive. What is best solution to keep running itunes normally in the future & get the CD/DVD drive working again? if I delete the upper / lower registry keys what other functions are impacted? I see others say itunes asks for a reinstall...then same problem all over again! THX

    Have you revieved this support document?
    TS2308: iTunes for Windows: Optical drive is no longer recognized, or "Disc burner or software not found" alert after install.
    tt2

  • Whats the best way to backup my iphone?

    Hello. I am brand new to iphones....actually to apple anything. Never owned an apple product.  I dont quite understand the whole itunes/icloud thing at all and I was hoping someone could explain it to me.  All that I wish to accomplish is make sure all of my stuff on my iphone(apps, pics, music, etc) is backed up regularly and in the event that my iphone is lost/stolen, breaks, needs to be replaced for any reason, or if I upgrade to a new iphone I would like to be able to recover everything. 
        OK, so far I have itunes installed on my laptop and I "sync" with that regularly (pretty much whenever I install a new app). But is my understanding correct that by syncing with itunes all of my stuff is stored locally on my laptop? If that is true, then what happens if my laptop crashes? So thats where I thought icloud came in. So I started backing up to icloud (via wifi in Settings>icLoud>storage&backup).  But I notice that when I backup this way it is actually only backing up a small amount of data (in-app data??) rather than the entire app. 
        I thought you would be able to sign into icloud.com and be able to view everything that you have ownership of or what you have backed up but that is not the case. I did download the icloud control panel to my laptop and it shows a little more information.
        So bottom line is I just need someone to explain how this stuff works and what the best course of action is for me to take regularly to make sure everything is safe, Thanks everyone!  I sincerely appreciate any help you can give me!!

    bjs19781978,
    There are 2 ways to back up as you have stated.  iTunes or iCloud.
    You are correct in saying iTunes backs up everything on your computer.  If you do lose your computer though, you will lose that information, but you would most likely still have your phone unless you lose your computer and phone at the same time which would royally suck.
    You can also back up to iCloud like you have said.  iCloud does not back up in the exact same way as iTunes, it only backs up application data, contacts, address books, and a few more things.  The advantage to this is it does it automatically if you are connected to wifi, the phone is locked, and the phone is plugged in.
    Look at this link to see exactly what iCloud does back up.  Hopefully this helps a little.
    Apple - iCloud - backup

  • One headphone does not work or works 50% of the time.  What is best way to resolve?

    one headphone does not work or works 50% of the time.  What is best way to resolve?

    First of all, I'd recomend resetting the iPod. Do this by pressing the 'Menu' and 'Center" buttons for 10 seconds or until the Apple logo appears.
    If this doesn't work, then it sounds like a hardware fault.
    To identify the issue, if you have one, try plugging the iPod into a speaker through the dock. If this works, then the issue is with the headphone jack. If not then the logic board is dead.  If the iPod is less than a year old, then it can be repaired by Apple for free. Just book an appointment for the Genius bar.
    If not then, you could see about sending it to an iPod Repair Company, such as my own. A replacement headphone jack would cost £30.00 in the UK, including next day delivery. Other companies you could try would beUKiPodRepairs, but we guarantee to beat any quote that you get.
    Hope that this helps,
    Mark Sweeney
    Dr Pod Founder

  • I am moving from PC to Mac.  My PC has two internal drives and I have a 3Tb external.  What is best way to move the data from the internal drives to Mac and the best way to make the external drive read write without losing data

    I am moving from PC to Mac.  My PC has two internal drives and I have a 3Tb external.  What is best way to move the data from the internal drives to Mac and the best way to make the external drive read write without losing data

    Paragon even has non-destriuctive conversion utility if you do want to change drive.
    Hard to imagine using 3TB that isn't NTFS. Mac uses GPT for default partition type as well as HFS+
    www.paragon-software.com
    Some general Apple Help www.apple.com/support/
    Also,
    Mac OS X Help
    http://www.apple.com/support/macbasics/
    Isolating Issues in Mac OS
    http://support.apple.com/kb/TS1388
    https://www.apple.com/support/osx/
    https://www.apple.com/support/quickassist/
    http://www.apple.com/support/mac101/help/
    http://www.apple.com/support/mac101/tour/
    Get Help with your Product
    http://docs.info.apple.com/article.html?artnum=304725
    Apple Mac App Store
    https://discussions.apple.com/community/mac_app_store/using_mac_apple_store
    How to Buy Mac OS X Mountain Lion/Lion
    http://www.apple.com/osx/how-to-upgrade/
    TimeMachine 101
    https://support.apple.com/kb/HT1427
    http://www.apple.com/support/timemachine
    Mac OS X Community
    https://discussions.apple.com/community/mac_os

  • Whats the best way to transfer everything from my old macbook pro to a new mac mini, i have a external hard drive which i backup to regularly via time capsule

    whats the best way to transfer everything from my old macbook pro to a new mac mini, i have a external hard drive which i backup to regularly via time capsule

    Check out > OS X Lion: How to use Migration Assistant to transfer files from another Mac

  • Wipe my hard drive clean except for the OS whats the best way?

    I need to wipe my hard drive clean except for the OS whats the best way?

    From Kappy (note: with this method, you will need to update to the present OS version using the appropriate Combo Update from Apple Downloads.)
    Boot from the OS X Installer Disc One that came with the computer. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities (Installer menu if using Panther or Jaguar) menu. After DU loads select the startup volume from the left side list then click on the Erase tab. Set the format type to Mac OS Extended (Journaled) then click on the Options button. Select the one pass Zero Data option and click on the OK button. Then click on the Erase button.
    Note: You can skip the Zero Data option if you are not concerned about removing sensitive personal data from the hard drive. If you choose to skip this part of the process then it is possible for others to recover data from the hard drive. The Zero Data procedure will prevent others from getting access to your personal information.
    This process will take 30 minutes to several hours depending upon the size of the hard drive. After formatting has completed quit DU and return to the installer. Now complete the OS X installation. At the completion of the installation do not restart the computer. Instead just shut it off. The next user will be presented with the Setup Assistant when they turn on the computer just as it would if new out of the box.
    https://discussions.apple.com/message/12364050?messageID=12364050#12364050

  • Hello I want to buy your iphone5 S of the U.S. site, but I want to use it in Saudi Arabia what is best option

    Hello I want to buy your iphone5 S of the U.S. site, but I want to use it in Saudi Arabia what is best option

    Check this link.
    https://www.apple.com/iphone/LTE/

  • What is best blue tooth presenter for macbook pro and air

    What is best Blue Tooth presenter for MacBook Pro and Air?

    You got lots of choices such as:
    WD Studio
    http://www.wdc.com/en/products/products.aspx?id=200
    WD Studio 2
    http://www.wdc.com/en/products/products.aspx?id=210
    WD My Book
    http://www.wdc.com/en/products/products.aspx?id=250
    Lacie:
    http://www.lacie.com/dk/products/range.htm?id=10007
    http://www.lacie.com/dk/products/range.htm?id=10036
    The are tons of external storage for mac out there but these are a few of them...
    I personally like the WD Studio 2 and the LaCie 2big Network 2

  • What is best filter for MacBook Pro

    What is best filter for my son's MacBook Pro to block adult/**** sites while allowing access to most anything else. The parental control I set up has not been the answer.  I constantly have to unlock sites for him.  I would appreciate any suggestion.

    If the options on the computer itself are not sufficient, you might try other options like OpenDNS Home, but it also involves a list that might need to be customized.
    In the end, the best defense is passing down a strong set of values so that when your son does visit the "wrong" site (as he inevitably will, and increasingly so into adulthood) he at least has an innate knowledge that he shouldn't be there.

Maybe you are looking for

  • Error loading plugins brs pencil tool | cc | Illustrator 2014

    Hello there, I use Illustrator cc 2014, and recently when I open the application, there will be a pop up with "error loading plugins brs pencil tool". I click continue, and the pencil tool is completely missing from my tool bar. I wanted to know what

  • Are nano sims available in Asia that will work in an iPad mini?

    If I take an ipad mini/att out of the US (Asia, India, Mexico) will I be able to find nano sims from local cell providers and use them in the device?

  • Create PDF From a backend web page

    Hello, this is my first post on the Adobe Forums I am trying to get a capture of a web page using Adobe Acrobe "Create PDF from Web Page" However, I cannot figure out how to capture a page after I have logged into the site. I thought that Adobe Acrob

  • File to IDOC (CREMAS03)

    Hi Experts,   I am trying to load Vendor data in the R/3 system, I got stuck up when I am trying to do mapping between file and IDOC, how can get CREMAS03 Idoc into XI.... Please help Thnx Raj

  • Request: AUR - Issue - Camunda

    Hi, I am interested in Camunda BPMN. It is a BPMN/BPEL Open Source SW for modelling Business Process/Workflows. I want to add it to my toolchain for building webservices, but I am an beginner in web programming. Can you provide an AUR package of camu