2 ms·
In Java, if you have something like void foo(Integer i) { // Putz with reflection, change value stored in i to something else } main() { foo(150); // Nothi
by nikanj 10y ago
In Java, if you have something like
void foo(Integer i)
{
// Putz with reflection, change value stored in i to something else
}
main()
{
foo(150); // Nothing special, you just created an autoboxed integer and then alter its value
foo(4); // Java pulls you an Integer from the autoboxing cache, and you do indeed accidentally alter the value of 4.
}
- PhasmaFelis 10y agoCan you tell me a bit more about reflection and autoboxing, or link to where I can learn myself?