Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

R K Singh

Ranch Hand
+ Follow
since Oct 15, 2001
R likes ...
Spring Java
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 Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by R K Singh

Paul Anilprem wrote:If you just return -1 , 0, and 1, you won't be able to order the objects efficiently.

I really doubt that returned value decide the order of object.

Its just lazy n quick practice of returning a -b for comparison.

Or am I missing something ??

Henry Wong wrote:
you are passing List<Poodle> and List<Dog> instances... and there isn't a IS-A relationship between List<Poodle> and List<Dog>.

If that is the case then why does dogsBark2(poodles, poodles); work ?

List<Poodel>, List<Poodle> is not List<Dog>, List<Dog>

or am I missing something ??

Any explanation will be really helpful.

What is the type of ncr ?

It is not declared in the lines you posted here.
I think you want to use incr reference variable at line 19.
3 years ago
oh man .. I dont want to be old but now remembering old good days means I am getting old ..

Anyways .. happy Valentine week to all :-)
3 years ago

Campbell Ritchie wrote:Naaaaa!

I have only been here about 11½ years.


you are old man bro ;-)
3 years ago
Came to the site after a long time ..

I find lot of new features and personalization added to the site.
Kudos to all who work voluntarily to maintain the website.

I am not sure how many old timers are still roaming around here.

Old members say Yaaa !!
3 years ago
All enhancements to java, I am sure will turn out to be useful.

But being a old student, I still feel that by allowing public/private methods to interface we are somehow taking interface to a point where the only difference with class will be that interface will not have state (member variables). And who knows Java 11 may have that too ;-)

Anyways, java was proud to have solution for diamond shape, but now we have resolution operator in java also.

Thanks a lot for your inputs.
4 years ago

I tried to find answer outside wide world, but I failed, so I am asking this question here:

What is the difference between Abstract Class and interface in java 8, if it allows interface to have implementation of method also ?

Thanks for helping in understanding the new concept.
4 years ago
Thanks Fred.

Though our application is doing million of transaction, luckily I am not doing any performance improvement right now :-)

It was an hypothetical question, cause sometime smart guys points out such small things in code without having any real data in hand :-|
4 years ago

I am assuming that we all familiar with Java String pool.

For quick recap:

The JVM performs some trickery while instantiating string literals to increase performance and decrease memory overhead. To cut down the number of String objects created in the JVM, the String class keeps a pool of strings. Each time your code create a string literal, the JVM checks the string literal pool first. If the string already exists in the pool, a reference to the pooled instance returns.

Now question is, what is better to use, may be for small performance gain, from the following :

Op:1) use a reference variable and point to the string literal and use that variable, instead of string literal

Op:2) dont create a reference variable and use string literal, where ever you want to use.

As per best practice, I should be doing Op:1.
I think that performance wise also Op:1 should be preferred as it will save time for JVM to look up literal pool everytime it finds literal.

But Op:1 also has a overhead of creating a object reference and then pointing it to a reference in literal pool.

Is JVM fast and smart enough to find string from literal pool quickly? (is finding string from pool is heavy weight operation ??)
creating a reference variable is light weight operation?

I hope I was able to explain my doubt.
4 years ago
I also learned it for 3 years (class 6, 7, and 8th), not optional, it was compulsory. And thats fine to know it and I wish that all state have it as mandatory subject.

But I dont know what to do with it except to read Ramayana or other ancient text. (just read, still cant understand much as not using day to day activities and need to look translation).

I doubt that it would be ever completely dead, as you need it for all occasions, from birth to marriage to new home to new car to death :-)

But it will be limited to Brahmins who would choose their profession to perform all rituals.
5 years ago
Let me try to explain :

a= new A[10]; a1= a;
b= new B[20];
a= b; // 1
b= (B[]) a; // 2
b= (B[]) a1; // 3

Following are references to memory location :

a = 1000 -> A[10]
a1=1000 -> because of a1 = a
b = 2000 -> B[20]

because of line //1
a = 2000

NOTE, a1 is still pointing to 1000

//2 require casting,

//3 will throw run time casting exception because a1 points to A[]

I am not sure how many non vegetarian really cut the meat and eat.

I think real poll would be to check, how many cut the living pork, chicken, beef and then eat it ;-)

I m sure butcher does it everyday.

PS: I eat all edible things. I am above Halal/Haram/Kosher etc. No offence to any foodie.
5 years ago
I wish Map was here to reply.

But anyways, Sanskrit is dead language like lot of other ancient languages.

You must have heard this saying, "देखो किस्मत का खेल, पढ़े लिखे फारसी और बेचे तेल" (see misfortune of the person, learned Persian and still selling low profit things).

There was a time when Persian language was also superior to all languages.

Language is often decided by Masters :-|

And more over, its money which drives a language.
People learn, speak the language that makes them to make/earn money.

A diamond is of no use, when you need food.
5 years ago
Thanks a lot.

I read it but did not understand it.

Please correct me, it means that all maven repository will be available on and I do not need to change my repo location in POM.xml

5 years ago