Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
wheaties
on March 20, 2013
|
parent
|
context
|
favorite
| on:
Java Puzzle: Square Root
I hate to break it to you but "n" is not final. Hence, you can reassign any BigInteger to it. Why not just set n = 9 and the root = 3...
Immutability is your friend. Use it or lose it.
craigching
on March 20, 2013
|
next
[–]
But n is also private, so you can't reassign it without using setAccessible or changing the security manager, both forbidden by the rules.
coolbrow
on March 20, 2013
|
prev
|
next
[–]
But "n" is private and the rules state the solution must be in a different class. Thus you can't simply reassign it.
tantalor
on March 20, 2013
|
prev
[–]
You can't assign anything to a private variable.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
Immutability is your friend. Use it or lose it.