Yes, there is a difference. Although both produce the same end effect, an iterator is not the same as a generator. The difference is in the way it is implemented and also consumed. Iterator is a (design/implementation) pattern while Generator is a language construct supported by the compiler. More ...
New things are not always instantly accepted. Beyond skepticism, new things challenge the comfort people are accustomed to. JINQ wasnβt particularly welcomed. It was either discarded as unknown angel or worse β¦ ridiculed. However, JINQ still promises expressive succinct code. More ...
JINQ (Java INtegrated Query) is an ultra minimalistic library inspired from and mimicking the .NET LINQ. While LINQ is a language level construct, JINQ is composed of types - classes and methods, but to the same effect.
I am really sorry if I tricked you into believing that Java is offering partial class feature. Unfortunately, Java doesnβt. Maybe never will. But I am going to talk about a workaround also presenting the thought process. Hence the length of the post. More ...
What are your thoughts on the following piece of code?
public String someGibberishMethod() {
int length = someMethodReturningLength();
int sum = 0;
for (int index = 0; index < length; ++index) {
// some code that updates the sum variable
}
SomeClass someClass = new SomeClass(sum);
int sumValueInsideSomeClass = someClass.getSumValue();
// use someText, maybe log or something
String someText = someClass.doSomeOperation(/*some parameters*/);
// use someText, maybe log or something
return someText;
}
If you are writing a typical console based application in Windows, you would end up with an executable (exe). You might also have one or more dependent libraries (DLL). The question is where do we place these DLLs so that they are picked up at runtime by the application; loaded and consumed. Actually it is no brainer, just put them along side the console application executable. Or you could place the DLLs in the System32 directory. Or you could add the directory to the PATH. Well, my point was actually to say that the DLLs can be simply placed alongside the executable and it would be picked up. More ...
It all began when I wanted to return more than one value from one of the methods. Although my attempts ended futile, it was fun exploring and musing how things could have been.
There are at least a couple of options to return multiple values from a method:-
In the recent interviews, I asked the candidates the following question:
Is there a difference that I need to consider in the following declarations? Both allocate fixed size array to store integers:
int[] na1 = new int[10];
Integer[] na2 = new Integer[10];