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.

substring problem
 Post subject: substring problem Post rating: 0   New post Posted: Mon 03 Jan, 2011, 02:55 

User rating: 0
Joined: Tue 15 Sep, 2009, 00:44
Posts: 20
The following code does not handle the substring correctly. It is printing the last line of code even when ShortAcctNm equals DEMO. I have just started to program in Java so I must be misunderstanding something. Please help. (I also checked to make sure it was the letter O not a zero)

public void onTick(Instrument instrument, ITick tick) throws JFException {
Ask = tick.getAsk();
Bid = tick.getBid();
TickTime = tick.getTime();

AcctNm=engine.getAccount();
String ShortAcctNm = AcctNm.substring(0,4);
console.getOut().println(":"+ShortAcctNm+":");
if (ShortAcctNm != "DEMO") console.getOut().println("xxx"); // this should not print for DEMO account

Messages
01:44:53 xxx
01:44:53 :DEMO:
01:44:53 xxx
01:44:53 :DEMO:
01:44:52 xxx
01:44:52 :DEMO:


 
 Post subject: Re: substring problem Post rating: 0   New post Posted: Wed 05 Jan, 2011, 08:32 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
ShortAcctNm != "DEMO"

change to

!ShortAcctNm.equals("DEMO")


 

Jump to:  

cron
  © 1998-2025 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