Why only +String concatation for Operator Overloading ?

Java does not support operator overloading other than the + operator for addition of two Strings or a number and a String.Why only the + operator and Strings, even when we have a concat() for addition of Strings ?
Wondering if anyone could provide me some link as to why this only this (+) operator was chosen.
Thank you for your consideration.
Edited by: amtidumpti on Apr 27, 2009 6:40 AM
Edited by: amtidumpti on Apr 27, 2009 6:40 AM

amtidumpti wrote:
stevejluke wrote:
amtidumpti wrote:
Java does not support operator overloading other than the + operator for addition of two Strings or a number and a String.Why only the + operator and Strings, even when we have a concat() for addition of Strings ? I assume the + was implemented (even with the concat() method present) for simplicity with working with Strings. Why only +? What other operators make sense as String manipulation operators? Why are they useful?We already have String,StringBuilder,StringBuffer for simplicity and manipulations of Strings or may be they were added later,but even then we have this +.Right, and you can use those methods instead of +. But String is a much-used class, has several special attributes given to it, and the + is very self-explanatory when applied to Strings.
Also would == qualify as the other operator for operator overloading in java ?== has no special meaning for Strings (or really for Objects at all). It has exactly one purpose, to compare the value of the operands provided. When the operands are primitives, it compares their values exactly as you or I would (if the primitive values are equal you get true). When the operands are reference types the value of the references are tested for equality (if they don't hold a reference to the same Object, then == returns false).
>
int iAge1=0,iAge2=0;
String sName1="Java",sName2="Rocks";
double dMark1=89.02,dMark2=92.0;
if(iAge1==iAge2)
System.out.println("HURRAH");
if(sName1==sName2)
System.out.println("HURRAH");
if(dMark1==dMark2)
System.out.println("HURRAH");Also in case of boolean :
boolean bFlag1=false,bFlag2=true;
if(bFlag1=bFlag2)
System.out.println("Value Assignment done");Here is " = " working not only as a assignment operator as well as conditional operator ?
Thanks for your consideration.

Similar Messages

  • String.concat() vs + operator in strings concatenations

    Whats the difference between String.concat() and + operator in strings concatenation?
    I cant find any functional one.
    Are there any performance differences?
    Thanks

    TM-Nite wrote:
    Whats the difference between String.concat() and + operator in strings concatenation?
    I cant find any functional one.There isn't any for all one can tell from the API docs. More details would be up to the String implementation.
    Are there any performance differences?No. Both are bad if repeated a lot, as long as there aren't exclusively compile-time constants involved. Use StringBuilder/StringBuffer instead, in those cases.

  • Why only associate certification for Weblogic 11g?

    I am wondering why there is no OCP path for weblogic 11g only a OCA? There is both a OCP and OCA for App server 10g - an end of life product and yet for the current product there is only an OCA.
    Which seems a little odd. Can you please explain? When can we expect an OCP level path for wblogic 11g.
    Cheers!
    Dave

    Hi Dave,
    The best explanation I have for that is just that it was a business decision. I'm sorry I can't give you a better answer. Perhaps there will be an OCP level in the next version.
    Regards,
    Brandye Barrington
    Certification Forum Moderator

  • Capctiy req. for operation and phase

    Hello,
    In the recipe i have 2 operations 10 and 20. Operation 20 is marked as phase. and superior opertaion is 10. In the planned order system shows capcity requirement for the operation 20 (which is phase).
    But in capacity evaluation t/c CM50 .it shows requirements for both the operations 10 and 20.
    I think , capacity req. should only be calculated for operation 20 .
    What is correct ?
    Regards
    ShankarR

    Hi,
    I have seen similar behaviour. is this correct? or CM50 does not work  with process orders?

  • Why only for me my webpage is little bit broken?

    Why only for me my webpage is little bit broken not showing correctly? With other browsers is OK, but then i using Firefox 4+ version it's little bit broken, my friends using same browser like me, but for they website looking good. Please help me, because i don't like use old firefox versions :/
    You can see how for me it look's: http://img818.imageshack.us/img818/8585/unledal.jpg At normally the text from panel's should little bit exposed from panel.

    Fix your coding so your web pages are displayed in "standards mode" rather then the "quirks mode". The problem with the quirks mode is that it forces Firefox to guess your intentions about how something is to be displayed, when your friends view that page Firefox guesses right, but for you Firefox is guessing wrong. Eliminate the "guess" factor and Firefox should display your web page the same for all users. <br />
    http://en.wikipedia.org/wiki/Quirks_Mode
    Plus, once you fix the code, maybe you can get rid of that NO IE logo that appears when someone uses IE to view that page. Times are changing, IE 8 and even more so IE9, can display web pages almost as good as Firefox, Opera, and Chrome, and if not the web page is more than likely at fault.

  • I have an older I Mac operating system 10.6.8 and want to upgrade.  I've been told that the only upgrade available for my machine is 10.7.5.  On what website can I find this upgrade or how do I find this upgrade on the Apple website?

    I have an older I Mac operating system 10.6.8 and want to upgrade.  I've been told that the only upgrade available for my machine is 10.7.5.  On what website can I find this upgrade or how do I find this upgrade on the Apple website?

    Choose About this Mac from the Apple menu, check if the computer has at least a Xeon or Core 2 Duo(not Core Duo) CPU and 2GB of RAM, and if it does, click here and order a download code for Lion 10.7.
    Back up your data and check your applications for compatibility before upgrading. In particular, Mac OS X 10.7 and newer don't support PowerPC programs such as versions of Microsoft Office prior to 2008.
    (116475)

  • Why is my mac so slow i have cleansed and cleaned it is a 2010 mac mini i5 but it runs like a 20 year old pc i have only had it for a few months and it was straight out of the box

    why is my mac so slow i have cleansed and cleaned it is a 2010 mac mini i5 but it runs like a 20 year old pc i have only had it for a few months and it was straight out of the box

    I'm thinking that you have a > Mac mini (Mid 2011) - Technical Specifications because the 2010 model's only have Core 2 Duo processors and the 2011 had the first i5 processor. 
    2 GB of RAM is the minimum requirement for Mountain Lion, but it's hardly enough to really enjoy doing anything else.
    see > Memory and Free Installation Guides for Apple Mac Mini
    Plus I don't have any problems running Mountain Lion and a load of App's on my 2010 Mac Mini with 8GB of RAM.

  • Photos from the Internet will not load correctly. I get white boxes with blue question marks inside. This has only been happening for the past 3 weeks so I'm not sure why it is happening.

    Photos from the Internet will not load correctly. I get white boxes with blue question marks inside. This has only been happening for the past 3 weeks so I'm not sure why it is happening.

    Yes - email &amp; text work fine but when I use something like Google Images or search a blog with imbedded photos I get the empty white boxes with question marks.  If I click the question mark it opens the photo but I can't possibly do that for EVERY image on EVERY page I search!?!?!  I've rebooted the iPad &amp; my wireless card several times but neither action helped.  Have any clue what I should do now?

  • Why only once for create recovery media???

    When I created recovery discs for my laptop using HP Recovery Manager, I got the message:
      You can only create recovery media once for your system. So ensure that you keep it in a safe place
    why only once?? what is the problem with creating the same discs again?
    what is the difference when creating the recovery discs with the Backup and Restore utils in Windows 7? is it also once only? what is the difference between discs created with Windows 7 versus HP Recovery Manager?

    I believe it is due to MS license agreement that only 1 set is allowed. You can of course use a CD/DVD burning program to copy the set you made.
    The Recovery set you burn restores the laptop back to factory shipped state. Recovery made with Win 7 utility is an image of the hdd that includes added programs, data ,photos,etc.You also need to burn the System repair disc to use with the backup. You can use it as often as you like.
    ******Clicking the Thumbs-Up button is a way to say -Thanks!.******
    **Click Accept as Solution on a Reply that solves your issue to help others**

  • [svn:bz-trunk] 10020: Had previously updated user-agent string for Opera 10 in resources/config/ services-config.xml on DataServices/trunk.

    Revision: 10020
    Author:   [email protected]
    Date:     2009-09-04 07:35:51 -0700 (Fri, 04 Sep 2009)
    Log Message:
    Had previously updated user-agent string for Opera 10 in resources/config/services-config.xml on DataServices/trunk. Forgot to do this for the file on BlazeDS/trunk.
    Modified Paths:
        blazeds/trunk/resources/config/services-config.xml

    Revision: 10020
    Author:   [email protected]
    Date:     2009-09-04 07:35:51 -0700 (Fri, 04 Sep 2009)
    Log Message:
    Had previously updated user-agent string for Opera 10 in resources/config/services-config.xml on DataServices/trunk. Forgot to do this for the file on BlazeDS/trunk.
    Modified Paths:
        blazeds/trunk/resources/config/services-config.xml

  • Am I the only Alien on earth? (why is it normal for APPLE not to merge...)

    I really can't understand why is so normal for MAC user to miss the simple funcionality of merge two folders. Let's say you have (for instance) a local folder on your mac with hundreds of subfolders and files, and you want to merge different files from another folder with the exact name on an external hdd. It's simply impossible unless you enter each single folders and copy the files manually.
    Is it normal??
    Is it normal that the solutions I've found involve the use of third part applications (which may cost up to 60$) or even use Windows or move everything on, let's say, dropbox, merge the two folders and download everything back.
    Really... I can't understand!
    Am I missing something about finder? There's a magic trick or a very very hidden option or an exotic mouse+keys combination?
    Thanks

    What's silly in the Joomla upgrade? If you have more than 4.000 files and the newer version only has few hundreds of them upgraded, is it silly to let you download these few hundreds so you can easily (and quick) update to a new version?
    It's not silly at all to expect to download only the changed files. What is silly is providing just those files in folders on a system that doesn't do folder merging and expecting the user to figure it out. If the makers of Joomla wish to properly support the Mac, they need to provide some way to install those changes for you... they don't even need to provide an installer, it could be as simple as a small script that asks where your Joomla installation is (if necessary) and then executes the Unix "cp" command the with -R and -n options.
    Of course, perhaps they're expecting that anyone administering a server with Joomla should already know how to do this.
    OK I see, mac users never ever use nested folders with more than three files
    Not at all. I've got many levels of nested folders. I've simply never needed to merge any of them, and can't conceive of a situation, other than something like the Joomla updates, where you might want to do that kind of thing with any significant frequency. If you're using it as a sync solution between two machines, there are far better methods.

  • Why "wait for operation complete" error ?

    HI,
    When I use the vi "Read multiple waveforms" there are an errors that appears in the VI "wait for operation complete" and I cannot found the cause of this error ! Can you bring me your help on this suject ?
    Thanks you beforehand
    Here my vi in LV2013
    Attachments:
    Sans titre 1.vi ‏17 KB

    It would have helped if you would have stated that this was for a Tektronix 7000 series scope.
    I see two possible issues here:
    1) The scope never sees the trigger and therefore never sees a waveform to capture
    2) The scope is setup to continuously capture waveforms.  Since the scope isn't stopping, it won't report being complete.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions

  • Export report Excel-Data Only works not,'not enough memory for operation'

    Hi all,
    we are using in our Software CrystalReport Version 11 Service Pack 5. Crystal report is intergated for .NET. We can not uninstall CrystalReport Version 11 Service Pack 5 to install another Version or another Service Pack.
    We are haveing problems to export report as Excel 97-2000 Data Only, "not enough memory for operation" message pop up after you try to export report as Excel data Only.
    Export Report as PDF is working fine.
    This problems are on Windows XP Sp3 and Vista. On Windows 7 we have no problem.
    Please, can somebody help me solving this problem, or to finde a workaround for Windows XP. Memory from PC is not the problem.
    Mit freundlichen Grüßen / Kind regards
    Odisej Nujiq

    Odisej, unfortunately, processes such as remote sessions are reserved for phone cases only. You can create a phone case here;
    http://store.businessobjects.com/store/bobjamer/en_US/pd/productID.98078100?resid=S6I@hgoHAkEAAGsiyVkAAAAR&rests=1282226845369
    Also, just as an FYI, see the blog [What are these 'support' forums good for anyhow?|/people/ludek.uher/blog/2011/04/07/what-are-these-support-forums-good-for-anyhow]
    Without phone support, you are left to do most of the foot work your self. On the forums, we can provide suggestions and guidance, but that is about it.
    Couple of things to note though. If you do create a phone case, one of the 1st things that you will be asked is to update your app to SP6 - unless you can prove the same issue exists with SP6 (see more bellow).
    Something I would recommend you try is to take an XP box, install SP6 on it, then install your app on it. If this works, your options are highly limited. E.g.; SP6...
    One other utility that may be worthwhile to use is [Process Monitor|http://technet.microsoft.com/en-ca/sysinternals/bb896645.aspx]. Run that on the XP box. In the logs, look for "Access Denied" error messages. Look for load or other issues with crxf_xls.dll, exportmodeller.dll and crtslv.dll.
    From your responses I am still not sure if you actually did run Modules and compared the results. This is much, much easier to do than working with ProcMon and I'd start there. To summarize, my troubleshooting plan (irrespective of the limits imposed on you) would be:
    1) Use Modules as this is the easiest thing you can do
    2) Try this with SP6 - more work that (1) above, but at least you are on the latest. If this works, banging your head into an SP5 wall will do you no good (like I said, irrespective of what ever limits...)
    3) Use ProcMon - not too difficult, but time consuming as you will be looking over 100s, possibly 1000s of lines and not being familiar with details of CR, this will take time.
    - Ludek

  • Why can't I download only English version for lightroom 5 that I purchased?

    Why can't I download only English version for lightroom 5 that I purchased?

    You can adjust the language of your Lightroom installation in the preferences for the Application.

  • I would like to know why I am beening charged 39.97 for somthing when I only bight somthing for .099

    I would like to know what and why I was charged $39.97 when I only got something for $0.99

    so why would you ask this question on a user forum?  How would we know what you purchased and why you were charged?
    Good grief!
    Call iTunes store support.

Maybe you are looking for