Abhinav Shukla

Greenhorn
+ Follow
since Jul 18, 2011
Abhinav likes ...
Eclipse IDE Firefox Browser 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
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Abhinav Shukla

Compiler cant choose between primitive and boxed type if combined with varargs.

To be more general, 'varargs primitive', 'varargs + boxed primitive' and 'vargs + widened primitive' are consindered same; and are not legal for overloading.

Example : int.. , long... and Integer... are one and same and give error when used for overloading.
Dear Kathy and Bert,

I request you to create a new EJB 3 certification guide. Not only because there arent any good books out there on the subject.. a "much needed K&B" is missing.
I just love your writing style and believe anyone who has ever read you does so.
Your study guide for Java Programmer certification is a must read for every Java-being on this planet. Please gift us with something like that ( or even better ) on EJB 3.

I believe every person who wants to learn EJB spec would be expecting the same from you.
(Of course neglecting the rare of the rarest case that someone who is really into Java doesnt know you two )

Many many thanks for books you have already written and for those too which you will write in future.

Best Regards,
Abhinav Shukla

SCBFKB - 100%
(Self Certified Big Fan of Kathy and Bert)

Not necessarily from right. It depends on your pattern.

Use ".*\"" and you will get 0 : 61 : Houston, we have a problem with "string one" and "string two" (Chopping from right)

Use "\".*" and you will get 32 : 78 : "string one" and "string two". Please respond. (Chopping from left)


In your case, source string is chopped from both ends. So you get 32 : 61 : "string one" and "string two"

Chopping is also called backing off and can occur from any end of source.


Rule of thumb : "Greedy quantifier returns the biggest possible search result."


i assume you mean to ask why ga.getI() will run "first"

not sure..
but its the way JVM works.. maybe they might have mentioned this in Java Language Specification.

hopefully someone else might have a different / better answer.
hi divyya, first the getI() method is called, and after that SOP runs.

Step by step , its like this :

1. ga.getI() is evaluated... so "Sub" prints.

2. sop runs as (1 + " " + 2) , ie, "1 2" gets printed.

Sudhanshu Mishra wrote:HI All,
Can i use access and non access modifiers in any combination while declaring a class's member or their is a specific rule?
Please guide me through.though i checked few cases and found that any order was working for declaration,but of course i would love to know the rule if any.
Thanks...



If you are asking about order.... yes, you can use any order; eg. 'static public' and 'public static' are same and so on...

If you are asking for legal combinations..
one important rule as Ankit mentioned is 'abstract methods cant have anything except public or protected'; eg. 'abstract synchronized' is invalid for methods.
Few others are :
Final variables cant be volatile.
Non-static, non top-level classes cant have static members.

You cannot inherit a top level class, so its meaningless to make it "protected"

PS : "inheriting a top class" is not same as "inherit from a top class".
1. Change Comparable to Comparable<Dog>

2. Change 'FirstGrade' to 'Dog' at line 9 in your code.

3. Change 'int size' to 'Integer size' as you cant use compareTo with primitives



Output : 2 2


Output :

Inner 2 : 1
Inner 3 : 1

Although as a data structure queues are generally FIFO, but in Java PriorityQueue is ordered either by user-defined priority or natural order.

ArrayDeque should be used for FIFO/LIFO implementations.
This may not be a great example but will hopefully help you understand the concept :