split query

N

Nicole.Winfrey

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

Andrew Thompson

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

Roedy Green

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.
 
J

John W. Kennedy

Andrew said:
have enough nouse

"nous" (or "νους"). Greek word.
--
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"
 
D

Daniel Pitts

Roedy said:
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. 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
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.
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
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.
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.
 
A

Andrew Thompson

"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.
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 
P

Patricia Shanahan

Roedy Green wrote:
....
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
 
L

Lew

Andrew said:
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.
 
J

John W. Kennedy

Andrew said:
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.

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.

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

Daniel Pitts

Roedy said:
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.

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.
 
D

Daniel Pitts

John said:
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.
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,148
Latest member
ElizbethDa
Top