Java - problem with IF Statement

I am having issues with the below piece of code.  I am using eclipse.  output is equal to "" but it does evaluate to true thereby not setting the value accordingly.  Any idea?

if(output == "")
{
    output = "Invalid characters entered."; 
}

Open in new window

LVL 2
CipherISAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

QPRCommented:
trim your variable in case it isn't exactly an empy string e.g " "
If it's still not working then debug your code and step through to make sure you are actually reaching this step
0
CipherISAuthor Commented:
Nope didn't fix it.  Does not go in the If Statement.  I've attached a snapshot.
output.jpg
0
QPRCommented:
Well if it never reaches the if statement then there is something up with the logic. Can you step through the code and see why it doesn't get there?
0
CipherISAuthor Commented:
i resolved it.

Ans is output.length == 0
0
CPColinSenior Java ArchitectCommented:
In the future, be sure to use String.equals() to compare a string. Using == to compare strings will not work.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.