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.

instrument.toString()
 Post subject: instrument.toString() Post rating: 0   New post Posted: Mon 15 Dec, 2008, 15:12 

User rating: 0
Joined: Mon 06 Oct, 2008, 02:34
Posts: 6
Hello !!

In the function public void onTick(Instrument instrument, ITick tick) throws JFException

I put "if (instrument.toString() == "EUR/GBP")" but my condition it's never true.. why ??

thank you for your help !! :D


 
 Post subject: Re: instrument.toString() Post rating: 0   New post Posted: Mon 15 Dec, 2008, 15:34 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello,
When you compare two objects with ==, you compare not the content of the objects, but objects themself. You can think of it as comparing two pointers to the memory. Even if two strings have the same text, they are still different objects and have different pointers and == with give false. You should use:
if (instrument.toString().equals("EUR/GBP"))


 

Jump to:  

  © 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