Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming

Reply
 
LinkBack Thread Tools
Old 06-19-08   #1 (permalink)
Programmer
 
LyokoHaCk's Avatar
 
amd nvidia

Join Date: Aug 2006
Location: United States Inc.
Posts: 1,959

Rep: 73 LyokoHaCk is acknowledged by some
Unique Rep: 68
FAQs Submitted: 1
Trader Rating: 2
Default Java List.Contains -- Case Insensitive?

Is there a way to use List.Contains(var) in case-insensitive form? E.g. if the list had "LyokoHaCk" and I plugged in "lyokohack" for the variable, it would still return true.

I've tried iterating this and converting it to a string array then looping, but no luck!

Thanks for the help!
LyokoHaCk is offline   Reply With Quote
Old 06-20-08   #2 (permalink)
Kernel Sanders
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 4,894
Blog Entries: 1

Rep: 548 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 326
FAQs Submitted: 6
Trader Rating: 5
Default

Here's a method to do what you want. A quick browse of the API didn't turn up any way to do it without writing some code of your own.

Code:
public boolean containsIgnoreCase(List <String> l, String s){
 Iterator <String> it = l.iterator();
 while(it.hasNext()){
  if(it.next().equalsIgnoreCase(s))
  return true;
 }
 return false;
}
__________________
BIG BROTHER
I put on my robe and wizard hat...

IS WATCHING

System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 06-20-08   #3 (permalink)
Programmer
 
LyokoHaCk's Avatar
 
amd nvidia

Join Date: Aug 2006
Location: United States Inc.
Posts: 1,959

Rep: 73 LyokoHaCk is acknowledged by some
Unique Rep: 68
FAQs Submitted: 1
Trader Rating: 2
Default

Quote:
Originally Posted by rabidgnome229 View Post
Here's a method to do what you want. A quick browse of the API didn't turn up any way to do it without writing some code of your own.

Code:
public boolean containsIgnoreCase(List <String> l, String s){
 Iterator <String> it = l.iterator();
 while(it.hasNext()){
  if(it.next().equalsIgnoreCase(s))
  return true;
 }
 return false;
}
Thank You very much, sir!
LyokoHaCk is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 12:17 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.11414 seconds with 9 queries