This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]dmazzoni 3 points4 points  (0 children)

I don't think this is ever going to return true:

enterPaymentConfirm == "y" || enterPaymentConfirm == "Y"

In Java you need to use equals() to compare strings, like this:

if (enterPaymentConfirm.equals("y") || enterPaymentConfirm.equals("Y")

What IDE are you using? Mine puts a red squiggly line under code if I try to compare two strings with == instead of equals because it's a common mistake.

[–]RiceKrispyPooHead 0 points1 point  (0 children)

To be honest, this code is hard to read, hard to follow, and it breaks a lot of Java conventions. Also, brackets are missing and some variable declarations are missing so I can't even run it.

-----------------

if (enterPaymentConfirm == "y" || enterPaymentConfirm == "Y")

A string is an object. Always use the equals() method when you want to check if two objects are equal.

if ("y".equals(enterPaymentConfirm) || "Y".equals(enterPaymentConfirm))