I'm confused about the split string method in the following cases.
String test = "ABC";
String[] arr = test.split(",");
The usual problem people have with split in this:
The split argument is NOT a simple String, but rather a regex
expression. $ ( ) * + - . < = ? [ \ ] ^ { | } characters have magic
meaning. They need to be quoted when you mean them literally. See
http://mindprod.com/jgloss/regex.html#QUOTING
This baffles people. However, your question
String test = "ABC";
String[] arr = test.split(",");
What's the value of arr? Is it null or it has arr[0] with the value of
"ABC"?
Should be solved easily with a simple experiment.
It baffles me when people ask questions like yours. It would be less
work, less typing and much faster to do the experiment than to post a
question.
I wonder what inhibits people from experimenting.
1. too many Star Trek episodes where computers explode given the
"wrong" inputs.
2. punishment as a child for asking questions.
3. punishment as a child for curiosity.
4. lack of confidence in your ability to perform experiments or lack
of confidence in the generality of experimental results. You prefer
the authority of another human.
I recall teaching a computer course to some women reentering the work
force as part of a government program. I asked them to pound some
random keys to prove to themselves the computer would not explode. I
meant this as a joke, and to ease the fear of making mistakes.
One woman asked "Which key should I hit". I said, "Any you like..
Close your eyes. Just hit any keys you like."
She burst into tears. She then reported me for abusing her by giving
her inadequate direction on what to do.
She was an extreme example of someone afraid to experiment, someone
terrified of making a mistake or doing something without explicit
permission.
At the opposite end are kids who are itching to press every button to
see if they can figure out what it does.
The kindest thing a parent can do is avoid squashing his children's
curiosity. That was one thing my parents did well.
"The reason is, that I'm doubtful about the temper of your flamingo.
Shall I try the experiment?'"
~ The Dutchess, Alice In Wonderland.