Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!

R K Singh

Ranch Hand
+ Follow
since Oct 15, 2001
R likes ...
Spring Java
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
3
Received in last 30 days
0
Total given
7
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by R K Singh

Monica Shiralkar wrote:

Campbell Ritchie wrote:What do you think, MS?



I have seen that at times and have wondered why were these kept in a single file instead of multiple. To me having 1 file per class looks more readable.



unless you dont want that class to be accessible by others
3 hours ago

It is programmed to look for the first class in the file, I think, regardless of its access. If you use the old way of compiling code, with javac and java, there is no requirement for the class with the main() method to be public, either.



My bad, never tried, and trusted the theory that class has to be public so that jvm may call its public main() method. (Or may be I assumed that class has to be public )

I think it may work if there is only one class in the package

Anyway, thanks for the clarification.
4 hours ago

Tanuj Bhatt wrote:
Also i now able to run the connection after changing all the path to jdk 1.8 but still i want to know how to run the mysql connection in jdk 11 and higher as per i know they don't have a separate jre folder to put connector jar file



May be JDK11 and higher needs different MySQL driver file.

But its sad if Oracle is not maintaining backward compatibility.

Campbell Ritchie wrote:DJ: Welcome to the Ranch

I don't know whether things are different on JDK13 but I had no difficulty getting this file to run:-



critchie@localhost directoryXXX]$ java SingleFileDemo.java Campbell Jeanne Liutauras Bear
SingleFile object with field = Campbell
SingleFile object with field = Jeanne
SingleFile object with field = Liutauras
SingleFile object with field = Bear




how can JVM run without class being public ??

or am I missing something ??
2 weeks ago

Mohana Mahalingam wrote:

1)When I execute the above program, answer is
Value2found at2,0
Can you explain how the value 2,0 is obtained when Break Parent_Loop is replaced with Break statement?

2) When I execute the same with Continue parent_Loop the same answer is obtained.
Can we consider break and labelled Continue statements as the same?

3) When the program is executed with Continue statement, the answer is Value found at 2,1.

Please provide explanations how these statements are working
Thanks in advance



hmmm... These are basics as everyone advised, you should try it to get yourself using pencil paper or learning about them, in your case, you should learn more about break and continue.

You seem to be not able to understand break and continue.

I will try to provide pointers here, you have to explore more by yourself.

break :
break is used to come out of the immediate loop on meeting some condition.
break with label will come out of the labelled loop on meeting some condition.

continue :
continue is used to skip the rest of the execution on meeting some condition, and makes the program to execute the next iteration in your loop.

All the best

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.

TIA
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
Friends,

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 :-|
5 years ago
Hi

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 ??)
OR
creating a reference variable is light weight operation?


I hope I was able to explain my doubt.
5 years ago