Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF esleif statement

Status
Not open for further replies.

technohead

Technical User
Jan 12, 2002
64
US
im just wondering is this statement right cos every time i run it it always brings back the first redirect even if it should be the second one.


if(userType.equals("C"))
{
response.sendRedirect(" }
else if(userType.equals("B"))
{
response.sendRedirect(" }
else
{
response.sendRedirect(" }
 
public class IfElseDemo {
public static void main(String[] args) {

int testscore = 76;
char grade;

if (testscore >= 90) {
grade = 'A';
} else if (testscore >= 80) {
grade = 'B';
} else if (testscore >= 70) {
grade = 'C';
} else if (testscore >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
}
}
 
The trailing ;); characters mean it won't compile, perhaps you are therefore running an older version of the .class prior to this code being added.
 
you can use the following.

try using

if(userType.equals("C"))
{
response.sendRedirect(" }
else if(userType.equals("B"))
{
response.sendRedirect(" }
else
{
response.sendRedirect(" }



Note the difference in the lines as they do not have ";);"

Then you must also have the datatype for userType as String.
 
??? your code is the same os the original, the arguments of sendRedirect are not correct.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top