This week's book giveaway is in the Java in General forum.
We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line!
See this thread for details.

Gautam Arora

Greenhorn
+ Follow
since Jan 16, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Gautam Arora

I think the question asks you to enter select all correct options and not the specific order (though the order you have given is correct).

Just curious, why cant you compile a program at work. I would guess that you are a programmer and should have access to javac and java
Thanks Chandra.
I completely understand the limits concept. But have a few doubts in the examples.

Input "boo:and:foo"

But, after "b" why do we get just a single empty string "" and not 2 empty strings.

As o is applied as the regex pattern, should we not get 2 empty strings:
1. "" from start index = 1 to end index = 1
2. "" from start index = 2 to end index = 2

Just like in the end ":and:f" is followed by 2 empty strings.

Also, if the above case would be true then the array length can only be 5, so our output would be
{ "b", "", "", ":and:f", "" }
where the last empty string contains both the last 2 empty strings as per javadoc.
[ May 24, 2007: Message edited by: Gautam Arora ]
Hello,
Thanks to everyone on this thread. The regex ques in K&B had completely left me a lil bummed and lowered my confidence in this topic. Now I guess I'm back on track with some great info on split() and regex.

Some queries w.r.t limit in the split(regex,limit):
1. The difference between 0 and -1 is pretty clear, it will be the same output minus the last empty string in case of 0. Am I correct?

2. I'm still not clear what exactly is meant by limit and its usage of non-negative and negative numbers. Any examples with explanations?

Regards,
Gautam Arora
Yes, SCJP5 would be a better investment in terms of the effort you put in.
I'm preparing for SCJP5 too, and the new topics, though take some time to get a grip over, are worth the extra effort. The new features are here to stay.

Regards,
Gautam Arora