• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do you compare a string using this...

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,
This is my first post on the JAVARANCH and hopefully many more to come, I would like to know how would use an if statement like:

I am using an array here below and want to achieve the same result
as the bottom if statement. I am trying to check and see if
show_type.get(i) matches a string, but I do not know the correct syntax.
<% if ( show_type.get(i)"not sure how to code goes right here" ) { %>
blah blah blah
<% } %>
I am trying to achieve the result similar to the example below:
<% if ( show_type.equals( "Y" ) ) { %>
blah blah blah
<% } %>
Hope yall Can helP!..Thanks!
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Johnny T:
I am using an array here below and want to achieve the same result
as the bottom if statement. I am trying to check and see if
show_type.get(i) matches a string, but I do not know the correct syntax.
Hope yall Can helP!..Thanks!


Assuming that show_type.get(i) returns a string value, then you would use
 
Joah Nguyen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think I tried that out, but I'll try it again thanks!....Charles
 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Johnny, You say you are using an array but show_type.get(i) would indicate that you are using a Vector or ArrayList. Please clarify.
If using an ArrayList:
if(show_type.get(i).toString().equals("Y")){
...
}
or
if(((String)show_type.get(i)).equals("Y")){
...
}
 
Joah Nguyen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I am using an ArrayList! I'll will try that out Thanks Again
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch Johnny T!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
Thanks!
bear
JSP Bartender
[ August 29, 2003: Message edited by: Bear Bibeault ]
 
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic