Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

split query

Thread view: 
Nicole.Winfrey@gmail.com - 26 Oct 2007 13:28 GMT
I know that the split method is used to produce an array of strings
separated by the argument.

I'm confused about the split string method in the following cases.

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"?

String test2 = "";
String[] arr2 = test2.split(",");

What's the value of arr2? Is it null or it has arr[0] with the value
of ""?
Andrew Thompson - 26 Oct 2007 13:41 GMT
>I know that the split method is used to produce an array of strings
>separated by the argument.
>
>I'm confused about the split string method in the following cases.

Somebody posting to c.l.j.p. would normally be expected
to have enough nouse to write a short test program that could
answer the very questions you ask.

Why not try that?

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Lew - 26 Oct 2007 14:20 GMT
> ... a short test program that could
> answer the very questions you ask.
>
> Why not try that?

One of the benefits of writing and deploying an SSCCE
<http://www.physci.org/codes/sscce.html>
is that it very often answers the question for you.

Signature

Lew

Andrew Thompson - 26 Oct 2007 15:29 GMT
>> ... a short test program that could
>> answer the very questions you ask.
[quoted text clipped - 4 lines]
><http://www.physci.org/codes/sscce.html>
>is that it very often answers the question for you.

An excellent point.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

John W. Kennedy - 26 Oct 2007 18:59 GMT
> have enough nouse

"nous" (or "νους"). Greek word.
Signature

John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
  -- Charles Williams.  "Judgement at Chelmsford"

Andrew Thompson - 27 Oct 2007 08:42 GMT
> > have enough nouse
>
> "nous" (or "    "). Greek word.

Oops!  My bad.  Bad enough that I am using obscure
words, worse that they are neither English*, nor
correctly spelt!

Since the definitions point out that the word
'nous' has many different meanings, I will
clarify that I actually meant 'common sense'.

* If only for the reason that people might be
expecting 'English' here.

Andrew T.
Lew - 27 Oct 2007 14:44 GMT
> Since the definitions point out that the word
> 'nous' has many different meanings, I will
> clarify that I actually meant 'common sense'.

If you don't get /nous/ into your head, you might get your head into a noose.

Signature

Lew

John W. Kennedy - 27 Oct 2007 16:15 GMT
>>> have enough nouse
>> "nous" (or "    "). Greek word.
[quoted text clipped - 9 lines]
> * If only for the reason that people might be
> expecting 'English' here.

The sense you meant is sufficiently known (as a British slang
expression) to be in larger dictionaries, and I, though an 'umble Yank,
already knew it from somewhere or other.

Signature

John W. Kennedy
"You can, if you wish, class all science-fiction together; but it is
about as perceptive as classing the works of Ballantyne, Conrad and W.
W. Jacobs together as the 'sea-story' and then criticizing _that_."
  -- C. S. Lewis.  "An Experiment in Criticism"

Daniel Pitts - 27 Oct 2007 17:46 GMT
>>>> have enough nouse
>>> "nous" (or "    "). Greek word.
[quoted text clipped - 13 lines]
> expression) to be in larger dictionaries, and I, though an 'umble Yank,
> already knew it from somewhere or other.

Yeah, but you're into reading lit., so you have a wider experience than
the average American. (Doesn't Yank mean something else in British en_UK?)

From context, I simply took it as a word I didn't understand that meant
something that someone *should* have.  Being clarified as common sense,
it turns out I was right.

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Roedy Green - 26 Oct 2007 17:50 GMT
>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.

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Daniel Pitts - 26 Oct 2007 20:03 GMT
>> I'm confused about the split string method in the following cases.
>>
[quoted text clipped - 25 lines]
> 1. too many Star Trek episodes where computers explode given the
> "wrong" inputs.
Hah, hadn't considered that.

> 2. punishment as a child for asking questions.
>
> 3. punishment as a child for curiosity.
me thinks 2 and 3 amount to the same thing.

> 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'm mostly self taught.  I always experimented with everything, except
when I *first* started learning about multithreaded programming. I had
heard so many people say that its so difficult to get right, and that
the code could appear to work, but not be "correct".  This put me off of
the subject for a while until I realized that there was a finite
(actually small) set of rules which you could reason with.  This gave me
the ability to "mentally" experiment with such scenarios.
Experimentation is definitely an invaluable process.

> 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
[quoted text clipped - 6 lines]
> She burst into tears.  She then reported me for abusing her by giving
> her inadequate direction on what to do.
This sounds like an exaggeration, but I believe it.  Many of my past
students have known the solution to a problem, but wouldn't attempt it
until I told them it was correct.

If someone has to tell you that you're correct, then you'll never
produce anything original.

> She was an extreme example of someone afraid to experiment, someone
> terrified of making a mistake or doing something without explicit
[quoted text clipped - 5 lines]
> The kindest thing a parent can do is avoid squashing his children's
> curiosity.  That was one thing my parents did well.
Agreed, There is a fine line between protecting the wellbeing of your
children and possessions, and causing harm in the form of fear of
experimenting.

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Roedy Green - 27 Oct 2007 13:14 GMT
On Fri, 26 Oct 2007 12:03:22 -0700, Daniel Pitts
<newsgroup.spamfilter@virtualinfinity.net> wrote, quoted or indirectly
quoted someone who said :

>> 2. punishment as a child for asking questions.
>>
>> 3. punishment as a child for curiosity.
>me thinks 2 and 3 amount to the same thing.

Curiosity would include taking things apart, poking around in parent's
belongings, attempting to use tools, wandering off to explore, wanting
to take large amounts of time to study interesting phenomena, interest
in things parents consider morbid like insects, road kill, books of
tropical diseases ...

Asking questions can sometimes just be a way to pass time. The answers
are not important. It is just something to do with a parent.  I can
remember asking questions I already knew the answers to when I ran out
of new ones.  It was almost like asking for a familiar bedtime story.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Roedy Green - 27 Oct 2007 13:25 GMT
On Fri, 26 Oct 2007 12:03:22 -0700, Daniel Pitts
<newsgroup.spamfilter@virtualinfinity.net> wrote, quoted or indirectly
quoted someone who said :

>This sounds like an exaggeration, but I believe it.
Strangely it is not.  What is odd is the other women in the class
chastised me as well.  I was dumbfounded. Their point was I should
have noticed how stressful this was for her and backed off, and that I
should apologise for giving her an impossible ill-defined task. I gave
her no algorithm to decide which key to kit.  Her reluctance for me
made no sense. It was not as though I was asking her to jump out of a
plane.

I had taught university level and children before, but never a group
such as this. It was completely different.

I talked about this with various people trying to understand what was
happening.

One person said, that older adults are extremely afraid of making a
mistake, especially a public mistake.. They would find it humiliating.
(I had noticed teaching university students a few would refuse to work
at the black board.) They want to know exactly what to do. They want
assurance the odds of making a mistake are extremely low.

It seems to me, you can't learn anything in computers until you are
willing to make hundreds of mistakes. You have to keep trying thing
after thing until you find something that works.  If you punish
yourself for failing to guess the right answer the first time, you
will become paralysed and incapable of solving any but the simplest
problems.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Patricia Shanahan - 27 Oct 2007 14:13 GMT
...
> It seems to me, you can't learn anything in computers until you are
> willing to make hundreds of mistakes. You have to keep trying thing
> after thing until you find something that works.  If you punish
> yourself for failing to guess the right answer the first time, you
> will become paralysed and incapable of solving any but the simplest
> problems.
...

I would delete "in computers" from the first sentence of this paragraph.
Learning almost any skill involves trying to exercise the skill before
you have acquired it.

Patricia
Daniel Pitts - 27 Oct 2007 17:43 GMT
> On Fri, 26 Oct 2007 12:03:22 -0700, Daniel Pitts
> <newsgroup.spamfilter@virtualinfinity.net> wrote, quoted or indirectly
[quoted text clipped - 27 lines]
> will become paralysed and incapable of solving any but the simplest
> problems.

Man, I would have apologized. I'm sorry you're too stupid to learn
computers.   Just kidding.

Although, my with my personality I would have apologized, not for my
methodology, but because I didn't notice/realize the distress I was
causing.  I can see how most people in your situation wouldn't
apologize.  I don't think you're wrong.

I also agree that the fear of mistakes is debilitating to would-be
students.  Even I fall prey to that fear at times.  As soon as I get
over it, I tend to do better than many of my peers.
Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Roedy Green - 27 Oct 2007 13:32 GMT
On Fri, 26 Oct 2007 12:03:22 -0700, Daniel Pitts
<newsgroup.spamfilter@virtualinfinity.net> wrote, quoted or indirectly
quoted someone who said :

>This sounds like an exaggeration, but I believe it.

The fact I left out was these women had been out of the work force for
a very long time, and were having minor psychological problems
reintegrating. They were a very timid group, possibly abuse survivors.
My course was supposed to give them a gentle, low-pressure
introduction to computers.  I was known for teaching in a light
humorous way.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.