if matches logical iff.
boolean result; if (vData.equals("S")) result = true; else result = false;
or
boolean result = vData.equals("S") ? true : false;
or
boolean result = vData.equals("S");
EDIT: However, most likely, you do not need a variable, instead you can influence the result. eg.
if (vData.equals("S")) { // do something } else { // do something else }
BTW can be considered good practice to use
if ("S".equals(vData)) {
The difference is that vData is null, the first example will throw an exception, while the second will be false. You must ask yourself what you would rather do.
Peter Lawrey
source share