Could anyone please explain what is Idempotent method in Java?
After google, what I found about this is Idempotent methods are methods, which are written in such a way that repeated calls to the same method with the same arguments yield same results. And am not getting any example to clear the concept of it.
Every method if called with same arguments will yield same result. Then what is the difference between Idempotenet method and normal method?
Thanks in advance...
java_programmer
0
Junior Poster
Recommended Answers
Jump to PostConsider these two methods:
int sum(int a, int b) idempotent - every call gives same result
void writeToDatabase(String a) not. database gets bigger with every callor
String toString() idempotent
int getNextPrimeNumber() each call gives a different result
Jump to PostCould anyone please explain what is Idempotent method in Java?
After google, what I found about this is Idempotent methods are methods, which are written in such a way that repeated calls to the same method with the same arguments yield same results. And am not getting any example to …
All 7 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
hal arnold
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
hal arnold
0
Newbie Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
java_programmer
0
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.