Ankit Garg

+ Follow
since Aug 03, 2008
Ankit likes ...
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
Forum Moderator
Ankit Garg currently moderates these forums:
Bangalore, India
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ankit Garg

Although this is old, but on Java 6 or before since the pool was in PermGen, so following code results in false as the intern method call creates a new String in PermGen and s0 and s1 refer to different String objects:

Welcome Cay. I loved your Core Java Vol I & II (I had the 7th Edition) and I'm going through the Scala for the Impatient and loving it as well
1 year ago
If you just want to print the output on console then use Arrays.toString...
That's a good point. \b matches boundary at the start of the String also. So my guess is even if the space before 2 is matched in the previous match (with \D), \b can consider 2 to be start of a String and match it as a word boundary...
In the example add/offer method is not blocking. Only the transfer method is blocking because that's its purpose. This is what the documentation of the method says:

javadoc wrote:Transfers the element to a consumer, waiting if necessary to do so.
More precisely, transfers the specified element immediately if there exists a consumer already waiting to receive it (in take() or timed poll), else inserts the specified element at the tail of this queue and waits until the element is received by a consumer.

If you split by non-whitespace character, why would it split by the spaces? It would split by all characters which are not spaces. So it would split for each non-space character. By that theory the count is lesser and that's because split method removes all trailing empty elements. If you print the tokens array you'll see that it is generating blank tokens (and tokens with spaces)...
I don't have the book at hand, but are you sure the example says the add/offer methods are blocked/throws exception?
Hi Johnny, welcome to JavaRanch.

Many mock exams cover stuff which is not covered in the exam. They probably do it probably to make it difficult so that you think it is the best mock exam

Best resource to check what is or is not on the exam is to check exam objectives. But if you come across any question which is not covered in the book, the extra knowledge won't hurt so probably briefly reading about the topic should be good for knowledge (if not the exam)...
From what I've seen in my career so far, even with single page applications the login page is separate. That way you don't send all your client logic to any unauthorized user. Once user is logged in, the user is sent to the single page application which has all the functionality. So IMO you should go with the first approach instead of Kendo showing a login page. But that's just my opinion on the matter
1 year ago
Proxy pattern may or may not be used in AOP, it depends on the implementation but yes for Spring it is used. Same goes for singletons, Spring beans may or may not be singletons and spring beans being singleton has nothing to do with AOP. You can even say that AOP is like Decorator design pattern. But more than design patterns, AOP is about the issues it solves. It gives you a way to handle cross cutting concerns...
1 year ago
Hi Shahana, I think you are thinking of regex incorrectly. The entire pattern is matched multiple times. So the first time "\\b\\w+\\D\\b" matches "OCPJP ", then next time it matches "2013 ". The next time it didn't match because OCPJP7 had a number in the end which didn't match \D and there was no space at the end. "2013 " matched because \D matched the space after 2013...
Agreed, if this is not mentioned it should be mentioned. Also you cannot declare all type of final variables, it needs to be a compile time constant so it is limited to String and primitive types. So if you try to do this it will not compile:

I'm assuming you've modified the code to make the methods and fields static. Singleton is more powerful than using a class with everything static in some cases:

Polymorphism: Since the singleton is an instance, you can use the instance as a regular object. So you can pass it to other methods which is especially useful if your singleton class implements an interface.

Lazy Loading: If the singleton object is heavy, you can lazy load it inside the getInstance method...
Welcome David to the forums...
As a quick check, can you put a println statement in the retrieveInterstepDataFromJobContext to make sure it is being called...
1 year ago