I am a bit rusty on my Java. I have an array with several values one of which is used in an if statement.
It’s a single character I’m checking and the fact that it’s not working leads me to believe it may be a whitespace issue. The data is coming in from a mysql database and I already tried using trim() on the query to get rid of any whitespaces but no luck.
Here’s the code:
Payoff payoff=new PlainVanillaPayoff(Option.Type.Put,Strike);
if(inputData[8] == "C"){
System.out.println("TypeCall"); // Check to see whether if stmt is ever true.
payoff=new PlainVanillaPayoff(Option.Type.Call,Strike);
} else{}
The print statement called inside the if statement never prints.
Any suggestions?
This is because you are comparing
Strings using==. You should useequalsinstead.