|
![](/i/fill.gif) |
On 6/10/2011 8:05, Le_Forgeron wrote:
> Le 10/06/2011 16:45, Darren New a écrit :
>> On 6/10/2011 1:18, Le_Forgeron wrote:
>>> For instance, in Java, you can redefine the value of 3 and 6.
>>
>> Of all the languages out there, I'm pretty sure Java isn't one of thos
e.
>> :-) How do you redefine 3 to be 14?
>
> three years late slogan (for the USA): Yes We Can...
>
> http://thedailywtf.com/Articles/Disgruntled-Bomb-Java-Edition.aspx
>
> basically:
>
> import java.lang.*;
> ...
> Field field = Integer.class.getDeclaredField( "value" );
> field.setAccessible( true );
> int i=3;
> field.setInt(i,14);
> ...
>
>
> Integer a = 2;
> Integer b = 3;
>
> System.out.println( a + b );
That's not redefining the value of 3 and 6. That's redefining the value o
f
Integer(3) and Integer(6). The expression "2 + 3" will still return 5.
Note that in Fortran and FORTH at least, it's pretty trivial to make the
literal 3 refer to the value 15. (By "pretty trivial" I mean "you might
do
it by accident.")
--
Darren New, San Diego CA, USA (PST)
"Coding without comments is like
driving without turn signals."
Post a reply to this message
|
![](/i/fill.gif) |