aspose file tools
The moose likes Beginning Java and the fly likes Find special characters in string (Performance) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Find special characters in string (Performance)" Watch "Find special characters in string (Performance)" New topic
Author

Find special characters in string (Performance)

Martin Lira
Ranch Hand

Joined: May 26, 2004
Posts: 97
Hello Guys,
I need to create a method that determines if certain characters like


Which of this two ways is better in performance? Or is there any better way?


Thanks
Martin
[ April 03, 2006: Message edited by: Martin Lira ]
Alan Moore
Ranch Hand

Joined: May 06, 2004
Posts: 262
If no special characters are present, the first method will scan the whole string four times, while the second will only scan it once. Performance-wise, that's the only difference worth noticing, so you might as well go with the second method. But you're probably wasting your effort. Remember the three rules of optimization:

1. Don't do it.
2. Don't do it.
3. Before you do it, complete the app and profile it; the bottlenecks probably aren't where you expect them to be.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Find special characters in string (Performance)
 
Similar Threads
Power Strings
Set character formatting in Excel using POI
Check if an email-adress is valid with javascript
Simple precedence question.
New to Java - i need help please!