Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do you compare a string using this...

 
Joah Nguyen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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!
 
Charles Hasegawa
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Think I tried that out, but I'll try it again thanks!....Charles
 
Scott Duncan
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks, I am using an ArrayList! I'll will try that out Thanks Again
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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 ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic