Which one is better null == object or object == null

I am just surffing on a google and i found one new thing which is new concept to me, but that concept is not cleared
Concept is, i found one place a class object is compaired with the null in following way
if( null == object)
Usually i used
if(object == null)
Problem :- What is the diffrance between these two condition and which one is better?

yawmark wrote:
corlettk wrote:
So... Just use the first way (by default) because that's how people are it reading accustomed to.Agreed. Just to point out, the reason commonly given for preferring (null == object) is that it prevents semantic errors such as (object = null), which is only a problem in Java in a minuscule number of cases.And the practice started in C (or maybe even an earlier language) where it's an issue in many cases. For example,
int i = 0;
if (i = 1) { ... }The "if" line is illegal in Java, but it's legal in C. If the programmer forgets the second = sign, then you get the above. Variable i gets a value of 1, and the expression i = 1 has a value of 1, which corresponds to true (whereas in Java, you can't use an int where a boolean is expected). So the if comes out true, when it should have been false (had we properly used if (i == 1)), and in addition, the value of i has changed when we didn't want it to.
In Java, this would be a compile-time error, whereas in C, it's a runtime error. Compile-time errors are easier to fix, and they don't get the opportunity to cause a problem after the software has been released.
In C, to turn this back into a compile time error, you could get in the habit of writing if (1 == i) Then if you forget the second = sign, you get if (1 = i) which is a compile-time error.
Because Java doesn't equate numerical zero with false and non-zero with true, this issue is, as yawmark demonstrates, much less of a problem in Java.

Similar Messages

  • Business Delegate- JSP or JSP- JavaBean, which one is better?

    My current approach is to use a struts action to call a business delegate(pojo) which will go to the session facade and get database info then the JSP simply becames a FETCHER(which helps on reusablity since I can use them for many tables), but I also know I could use struts action to just simply forward to a JSP then retrive the info via JavaBean->EjbSessionFacade
    I'm confused which one is better for performance, scalability, maintainability, etc

    Whatever flow you are following is generally used flow and its correct aslo. Dont think its a bad design. One more think you have to look into is, minimize the remote calls as much as possible. Instead of doing many remote calls you can use EJB local object to process all your business logic and finally you can come out using single Remote call for a process. Look after this.. it will improve performance.

  • Creating default Row which one is better option

    hi,
    for creating dummy row in ViewObject which one is better and appropriate option..
    1) CreateInsert as default activity
    2) Creating row in Create method of ViewObjectImpl
    Regards
    Kiran
    Edited by: Kiran S on Aug 26, 2010 4:38 AM

    Kiran,
    CreateInsert is an action that is exposed via a data control. If you invoke this action, it will call the Create method of your View Object, so your question really doesn't make sense. If you need to have a row created and inserted into the row set of a VO, then using the CreateInsert action in a task flow will work just fine.
    John

  • I am going to buy a macbook pro for grade 12, and I need to know wheather I should get a macbook pro or a macbook pro retina. If someone could tell me (in a very simple way) which one is,better for me and why, I would be ever so apprreciative.

    I am going to buy a macbook pro for grade 12, and I need to know wheather I should get a macbook pro or a macbook pro retina. If someone could tell me (in a very simple way) which one is,better for me and why, I would be ever so apprreciative.

    Why do you need a expensive MacBook Pro?
    Your attending high school and unless everyone else is rich also your likely going to be a target by the more poorer students for theft or damage to the machine.
    You could keep it home, but if you need it for class then your exposed again.
    Also at that age your not very careful yet, a MacBook Pro is a expensive and easily damaged machine.
    Unless your made of money and so are others at your school, I would recommned a low profile, just does the job cheap Windows PC.
    If it dies, gets lost, stolen or damaged because of your inexperince handling senstivie electronics then it's no big deal.
    You can buy a Mac later on when your sure you have a need for it, currently there isn't much advantage of owning a Mac compared to a PC, they do just about the same things now, one just looks prettier than the other.
    Since 95% of the world uses Windows PC's your going to have to install Windows on the Mac in order to keep your skills up there or be unemployed, so it's a extra headache and expense.
    good luck

  • I am looking for macbookpro mid 2010 HDD exact specs so that i can upgrade it to 1TB. PLEASE HELP ME  about OEM apple brand or which one is better.Thanks

    I am looking for macbookpro mid 2010 HDD exact specs so that i can upgrade it to 1TB. PLEASE HELP ME  about OEM apple brand or which one is better?.Thanks

    clintonfrombirmingham Your information is not correct.
    http://kb.sandisk.com/app/answers/detail/a_id/8142/~/difference-between-sata-i,- sata-ii-and-sata-iii
    I have a sata II samsung 5400 rpm and i am only able to transfer at 85 read right speed.
    On my main drive sata III ocz agility 3 ssd i get 120 mb read and 180 write.
    Neither of these come close to the 300 mb promised. So it wont matter if he got sata II or III
    The speed came from Blackmagic Disk Speed Test

  • I would like to buy am Ipad for my nephew. Which one is better to play games, ipad or ipad mini

    I would like to buy an ipad for my nephew. Which one is better, ipad or ipad mini? He wants to play games, and put lots of app.

    Probably the full iPad, because it has a better graphics card. The larger screen helps too.

  • c:redirect VS RequestDispatcher -WHICH ONE IS BETTER TO USE?

    WHENVER WE WANT TO ACCESS FILES FROM OHTER APPLICATIONS,WHICH ONE IS BETTER TO USE,<c:redirect> OR
    RequestDispatcher

    Please stop shouting. It is considered rude.

  • , c:redirect OR RequestDispatcher -which one is better to use

    WHENVER WE WANT TO ACCESS FILES FROM OHTER APPLICATIONS,WHICH ONE IS BETTER TO USE,<c:redirect> OR
    RequestDispatcher

    <c:redirect> is the JSTL equivalent of the sendRedirect() method of javax.servlet.http.HttpServletResponse.
    Please see here:
    http://forum.java.sun.com/thread.jspa?forumID=45&threadID=405398 or search the forums for "RequestDispatcher redirect"

  • Shutdown or Sleep, which one is better??

    I usually use my Mac Mini about 3 hours a day. At the end of the day, should I shutdown the machine or simply put it in sleep mode? Which one is better? What is the difference?
    Mac Mini   Mac OS X (10.4.6)  

    791/3237
    Hi Snawman,
    I agree with the others. In your case, better shut it down for saving energy.
    "Which one is better? What is the difference?":
    - Sleep allows to very quickly resume any task that was running. Leave all applications, documents etc open, they'll just be here at the same place, in the same state, as when you left your computer.
    It's just a matter of quickly going back to work, not having to retype some websites login passwords for example, etc.
    - On the wear and tear point of view, the difference is so small, your Mini will be obsolete and replaced with a newer Mac, far before something breaks down just because of to many cold boots!
    Yes, the most demanding task for a computer's hardware (and probably OS too), is a cold boot.
    Sleep, instead of Shutdown, keeps your computer components from a lot of temperature fluctuations, and the hard disk too just spins down, instead of completely setting itself down, then up again from scratch (and cold).
    Again,
    these differences exist, but they are not so important that you would take them into account and change your energy saving habits.
    - Macs are well designed to cope with many different kinds of users/usages.
    "About running yourself the nightly automatic maintenance":
    In case you didn't know already about this: yes, just open Terminal and paste this command
    sudo periodic daily weekly monthly
    once or twice a month.
    In order to make sure all three maintenance tasks run until the end, after you entered your admin password and hit Return, just leave Terminal open like 15 minutes or so (until you see its prompt again).
    There is no hurry to quit it, as the maintenance runs in the background: Just use your computer in the meanwhile.
    Enjoy your Mac!
    Axl

  • If i have two option to select between XI or BW which one in better and why

    if i have two option to select between XI or BW which one in better and why
    both in terms of money and in terms of my career growth.......

    Sheetika,
    XI if you  are good in JAVA.The rest is same for both XI and BW.
    K.Kiran.

  • For developer's point of view which one is better- 10g or 11g

    guys please help me out.
    let me konw from developer's point of view which one is better 11g or 10g.
    i want to apply for oracle.

    user9342767 wrote:
    guys please help me out.
    let me konw from developer's point of view which one is better 11g or 10g.
    i want to apply for oracle.Assuming you are talking about Oracle Database 10g and Oracle Database 11g, and not any of the other products that use the brands 10g and 11g (and assuming you want to discuss that here instead of the appropriate product forum where it belongs), here are some of my thoughts:
    - if you are not using any 11g features, nor any new-in-10g features that have been fixed in 11g, it does not matter;
    - if you are using 11g features, then 11g is the way to go;
    - if you want (or want your customers to have) regular support past July of this year, go 11g;
    - if you want the latest fixes in the optimizer, go 11g;
    - if you want to save yourself code by using database features, look at the docs and see whether they will help.

  • Which one is better EP with ABAP or EP with Java

    Hi Experts,
    Please tell me Which one is better EP with ABAP or EP with Java for learning and useful in USA?
    Regards
    Jana

    What programming background do you already have?  You should match up the flavor of Web Dynpro that matches the skill sets you already have?  Do you have ERP or other Business Suite experience already?  If so you will find that WDA is often used in conjunction with the Business Suite and WDJ used for composites.  So consider where your business domain experience and knowledge lies and support that as well.

  • Create custom forms using code or SAP B1 Studio, which one is better?

    Hello Professionals,
    I'm new to SAP B1 9.0 SDK, i'm currently creating forms using code, but i noticed that it can be mad using SAP Business Studio,
    from your experience, which one is better for performance and quality wise?.
    Your help would be greatly appreciated
    Thanks in advance

    Hi Karem,
    http://www.mepa.ch/images/documentation/B1_90_WorkWithStudioSuite.pdf
    Please Refer The Link and Start Working with Studio..
    All the best
    Regards,
    Mayank Shah   

  • Macbook pro retina samsung panel, lg panel, which one is better?

    macbook pro retina samsung panel, lg panel, which one is better?

    grim992 wrote:
    So are the macbook pro retina early 2013 version with LG panel having IR issue?
    Mine hasn't yet but time may tell. At the same time I asked a question on the endless IR thread and never got an answer: to what extent is how the rMBP being used driving image retention?
    I'm sure there are other variables but the one that comes to mind first is how bright is the screen run? I would imagine that a monitor set to full brightness (as one user who complained about IR did) would accelerate any tendency toward IR and the closer to "full-on" it's set, the sooner that would happen. I have mine set to "5" of the available range and for the first week, I ran the Image Retention Test in all its variations repeatedly without a hint of IR. We also don't know whether the LG at full brightness can illuminate an auditorium while the Samsung can only light up a room or vice-versa.
    Other variables could be: is the screen saver used; how long before it kicks in; is the rMBP the only computer so it's used constantly; is it ever powered off or is the monitor just allowed to sleep?
    Based on those thousands of posts, the original LG's appear to be more prone to IR than the Samsung, but there hasn't been the same flood of complaints with the LG SJA2's, at least not yet. At the same time, there hasn't been any attention I could find about contributing factors either.
    And notably,  way back when the Samsung started to be the Holy Grail, I don't remember complaints about color problems; that seems to have cropped up recently.

  • DECODE VS  CASE? Which one is better

    Which one is better:
    DECODE(exp,1,val1,val2)
    VS
    Case WHEN exp = 1
    then val1
    when exp=0
    then val2
    end

    hi
    it depends on your environment in 9i you will find case faster then decode but when the same test scenario is test at 10g you will find the same.
    Khurram Siddiqui
    [email protected]

Maybe you are looking for

  • Crystal Report not visible when using IE9

    Hello, I have a report that has been displaying fine in IE8 for me, but when I upgraded to IE9, the report stopped displaying.  This problem seems to only occur if the report has more than 5 columns of data in it.   If it has 5 or less columns, every

  • Unable to view uploaded files in Tomcat till server is refreshed

    Hi All, I am building an application wherein the user would have an option to upload files (can be documents or images) and once the files are uploaded the user should be able to download it. I am using Apache Tomcat 6.0 and JDK1.6. Every thing seems

  • Desktop icons wont open when clicked on

    Hi to all Happy New Year just installed Leopard on both of my computers- on Macbook -desktop icons open when clicked on but not on my Imac computer- tried restarting numerous time any suggestions. Any thoughts. Kevin

  • Workflow workitem deletion

    Hi    I am triggering my workitem using FM SWE_EVENT_CREATE in this FM i am getting the event id  but for my requirement i want the workitem id so any body tell me how to get the workitem id . thanks srinivas

  • Does the iPad have external speakers, and can you also plug headphones into

    I've been thinking about getting an iPad. I was wondering if it had any sort of external speakers (or like the iPhone, doesn't, but still can project sound)? And also if you can plug a regular headphone jack into it. It seems like it would be pretty