Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

A problem about getComment()
 Post subject: A problem about getComment() Post rating: 0   New post Posted: Mon 22 Jan, 2018, 20:25 
User avatar

User rating: 0
Joined: Thu 24 Dec, 2015, 07:30
Posts: 8
Location: China, Kunming
Image
Image
Image

Hi, my dear Dukascopy,
My problem is very simple: Why these two things are not equal ???
I don't find anything wrong with my code, can you check it for me? Thanks a lot.... :) :) :)


Attachments:
Something.java [1.48 KiB]
Downloaded 81 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: A problem about getComment() Post rating: 0   New post Posted: Mon 22 Jan, 2018, 21:13 

User rating: 18
Joined: Thu 20 Apr, 2017, 22:42
Posts: 165
Location: Russian Federation,
I would say it is generally incorrect to use "==" or "!=" to compare objects in Java because these operators assume both object are same instances. There can be multiple instance of the String with same content. More appropriate way is
if( !"Regular".equals(myOrder.getComment() ) { ... }

I suspect the reason for two different instances of string "Regular" in you case case is that after update content of the 'local' order object is filled with data received from server and there will be another instance of string "Regular".


 
 Post subject: Re: A problem about getComment() Post rating: 0   New post Posted: Mon 22 Jan, 2018, 22:01 
User avatar

User rating: 0
Joined: Thu 24 Dec, 2015, 07:30
Posts: 8
Location: China, Kunming
Yes, yes , I just thought about it, but you have already made an answer. Big thanks!!!!!!!!!!!!!! :D :D :D :D :D


 

Jump to:  

cron
  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com