Hi Aaron
Aaron Prohaska wrote:
>
> I am trying to do something based on if key is equal to "AT", but I
am not > getting any results. It acts as if key is not equal to "AT",
but I can use > out.println(key) get "AT". Does anyone know why this
might not be working? >
> if (key == "AT") {
> ..do something...
> }
>
> thanks,
>
> Aaron
If key has a value "AT" and still it is saying that it is not equal to
"AT" then its only one mean that Key is of Objact type varaible. So u
can not compare it with == operator. Because when == operator is used
with objects then it checks to see if the objects being compared are
the same object instancs, and not whether the objects have the same
values. So if u want to compare for values then u have to use equals()
method of the Object class like this..........
if(key.equals("AT")
{
...
}
As i think it will help u
If not pl revert back.
Peeyush Bansal
Application developer
IBM, Delhi
______________________________ Reply Separator
_________________________________
Subject: Re: Problem with if statement
Author: maurice coyle <[EMAIL PROTECTED]> at INTERNET
Date: 9/8/00 9:12 AM
maybe you should try
if(key.equalsIgnoreCase("AT"){
...
}
works for me.
maurice
Aaron Prohaska wrote:
>
> I am trying to do something based on if key is equal to "AT", but I am not
> getting any results. It acts as if key is not equal to "AT", but I can use
> out.println(key) get "AT". Does anyone know why this might not be working?
>
> if (key == "AT") {
> ..do something...
> }
>
> thanks,
>
> Aaron
>
> <<:::..:::...::: Aaron Prohaska :::..:::...:::>>
> VerdeSoft Internet Services
> mailto:[EMAIL PROTECTED] http://www.verdesoft.net/
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
--
Maurice Coyle,
Sun Microsystems Ireland.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets