Tagged Questions
13
votes
2answers
1k views
Why does Java use UTF-16 for internal string representation?
I would imagine the reason was fast, array like access to the character at index, but some characters won't fit into 16 bits, so it wouldn't work...
So if you have to handle special cases anyways, ...
-4
votes
1answer
844 views
Test if char is '0'-'9' [closed]
My Java code is
// if the first character is not 0-9
if(
(((input.substring(0,0)).compareTo("1")) < 0 || (((input.substring(0,0)).compareTo("9")) < 0));
{
...
5
votes
3answers
846 views
When should I use StringBuilder or StringBuffer?
In a production web application, my fellow programmers used StringBuffer everywhere. Now I am taking care of application development and corrections. After reading StringBuilder and StringBuffer I ...
10
votes
5answers
2k views
Should a string constant be defined if it's only going to be used once?
We're implementing an adapter for Jaxen (an XPath library for Java) that allows us to use XPath to access the data model of our application.
This is done by implementing classes which map strings ...
0
votes
2answers
3k views
Best practice Java - String array constant and indexing it
For string constants its usual to use a class with final String values. But whats the best practice for storing string array. I want to store different categories in a constant array and everytime a ...
10
votes
6answers
722 views
What are the pros and cons of having a CaseInsensitiveString type in Java?
I'm tempted to create a final class CaseInsensitiveString implements CharSequence.
This would allow us to define variables and fields of this type, instead of using a regular String. We can also have ...
1
vote
3answers
2k views
Why does Java's String class not implement a more efficient indexOf()?
Following the below question on Stack Overflow
http://stackoverflow.com/questions/5564610/fast-alernative-for-stringindexofstring-str
I got to wondering why it is that java (6 at least) not use a ...