2
votes
Java - Should I use getter in method?
The name subscription suggests to me that the field contains detailed information about a subscription to some service. A subscription is not inherently a true-...
1
vote
Accepted
Redouble each occurrence of char recursively, and add n
You can calculate the number of doublings instead of looking it up in a map. The code below is otherwise copied from @Roman's answer.
...
1
vote
Redouble each occurrence of char recursively, and add n
Nested If-Statements
You can simplify the code and improve the readability as a result. It is achievable by using the Guard Pattern which in short can break off nested if-statements by inverting the ...
1
vote
Java - Should I use getter in method?
Both are fine. Just in first case scenario you could use the getter if needed by some other feature.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
java × 10870performance × 1273
algorithm × 1264
beginner × 1031
object-oriented × 720
android × 679
strings × 635
programming-challenge × 634
array × 499
multithreading × 447
swing × 412
game × 411
interview-questions × 353
design-patterns × 302
tree × 276
sorting × 266
linked-list × 255
spring × 221
recursion × 219
unit-testing × 197
parsing × 177
homework × 175
hash-map × 171
comparative-review × 169
time-limit-exceeded × 167