Conditional processing using parameters

Posted on 2003-03-04
Medium Priority
Last Modified: 2010-05-18
This has to be one of the simplest questions around!

I am completely new to Java and am attempting to manipulate some free source code.

I am trying to implement some basic logic like this:

theString = getParameter("theString")

if (theString == "aValuePassedIn") // perform next step
else // perform alternative step

Once compiled, the script never seems to make a match with the parameter value. I have tried strings, empty strings and integers, to no avail.

Question by:russback
1 Comment
LVL 86

Accepted Solution

CEHJ earned 150 total points
ID: 8064376
if (theString == "aValuePassedIn") // perform next step

should be

if (theString.equals("aValuePassedIn") )// perform next step

else your code is comparing object references, which is not the same thing

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month4 days, 2 hours left to enroll

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question