Anton Shaikin

Ranch Hand
+ Follow
since Dec 13, 2009
Anton likes ...
IntelliJ IDE Oracle Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
8
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anton Shaikin

Jeanne Boyarsky wrote:Agreed. This is already in our errata and was first discussed here



Oops, you're right. I initially thought it was on page 376, and therefore couldn't find it in the errata table.
The order of the arguments for accumulator function in 3-argument reduce method is invalid:



(c, s1) should be (s1, c) instead, according to the method signature:

Wrong explanation of read(byte[]) method:

"if the value returned is 0, then we know that we have reached the end of the file"

Method read(byte[]) returns -1 when end of file is reached.

Jeanne Boyarsky wrote:Agreed and noted. Good catch!


Hi Jeanne, in the sentence before, the phrase "There are three optional types for primitives: DoubleSupplier, IntSupplier and LongSupplier" should be replaced with "OptionalDouble, OptionalInt, OptionalLong", I think.
Just before this sentence, there is another typo. "Then we then want them sorted". Should be ""Then we want them sorted".
But even if you fix both typos, these 3 sentences that go one after another don't sound very well: "Then we want them sorted. Then we want the first two. Then we want to print them out".

This is the explanation for the following snippet:
stream.filter(n -> n.length() == 4).sorted().limit(2).forEach(System.out::println);

I think it'd be better to slightly change the wording, e.g. "Then we want to process only two elements".

Jeanne Boyarsky wrote:The Collections class *has* a few methods .



But if you meant Collections, the class, then the whole sentence wouldn't make sense: "Collections has a few methods that take lambdas, including removeIf(), forEach(), and merge().", because these methods are part of Collection, and Map classes.
Hi Jeanne,

Regarding your comment on the errata:

Chapter 3 In the second paragraph, “Collection has a few methods” should be “Collections has a few methods.” The idea was to include all the Collections types (Map has merge).



The part in bold should be "Collections have a few methods", if you mean Collections in general. Also, to avoid confusion with the Collections class, wouldn't it be better to say "Collections classes have a few methods" or "Java Collections Framework has a few methods"?
Sorry, if it was reported before, but I couldn't find.

p. 160:

"HashMap - Uses hashcode() to find keys"

should be hashCode.


p. 161:

Collection has a few methods that take lambdas, including removeIf(), forEach(), and merge().

Collection doesn't have merge() method, Map does.

do not confuse with TDD and JUnit.


I guess by JUnit you meant unit testing in general. If so, then I don't. The question was exactly regarding TDD. By given example I just showed how business logic is implemented in our project. I wasn't going to use TDD for existing code. That would be test-driven refactoring though, which also has a right to exist.
13 years ago

Prabhakar Reddy Bokka wrote:Yes. Definitely its a good practice.


Well, many would disagree. I read many articles on TDD that say that you should only test your public interface.
13 years ago
Also, to encourage Java cross-platform paradigm, you should better use System.getProperty("line.separator") which will return "\r\n" for Windows and "\n" for Linux.
13 years ago
Recently, there was a lot of buzz about Red Hat's JSR for Distributed Hash Table, called Infinispan. You can read more about it here While I'm not sure whether it's going to be approved, and it's too early to talk about Java EE 7, it gives us optimistic thoughts that someday DHT in Java might become an open standard...
13 years ago
Right, client does not need to know implementation details. But it has to have interface to your bean on classpath to call EJB methods on it.

Gaurav Swaroop wrote:Other option is to move the business logic from ejb method to another method (public or package private) and test that method.


Can't do that. The project is pretty old and I don't really want to violate its evolved coding style.

Prabhakar Reddy Bokka wrote:We can test private methods also using reflection API.


Yeah, I know. But the question wasn't about how to test private methods, but about whether it's a good practice.

Thanks to all anyway.
13 years ago

That looks like a job for positive lookahead / lookbehind


Exactly, and that goes far beyond the "Beginning Java". Regular expressions are all about formalizing your requirements, so first you have to define what you mean by "word". Because, according to the common regexp vocabulary, a word character could be described by the following pattern [a-zA-Z_0-9]. As I see in your case, you mean something different.
13 years ago