Computer Science Canada turing equivalent |
Author: | Homer_simpson [ Fri Feb 13, 2004 2:11 pm ] |
Post subject: | turing equivalent |
you know in turing when u wanna declare a procedure that could change the value of arguments you would go like this: procedure blah(var args:int) args:=3 end blah now in java when i make a procedure... i can't change the value of my arguments inside my procedure... i need to know how to do that... |
Author: | rizzix [ Fri Feb 13, 2004 3:42 pm ] |
Post subject: | |
well if it is a primitive: int, double, float, char, byte, short, long etc... you can't since primitives are passed my value. What u can do is use the Integer, Float, Double... etc.. encapsulation classes instead. Objects are passed by reference. so yep! you can do that. but i should point out.. thats bad coding in java terms. in java, in fact most pure OOP languages: never change the contents of the arguments unless absolutely necessary |
Author: | wtd [ Fri Feb 13, 2004 5:49 pm ] | ||
Post subject: | |||
Indeed, the only way you could achieve something like this is by having the procedure alter an instance or static variable.
|
Author: | Homer_simpson [ Fri Feb 13, 2004 8:18 pm ] |
Post subject: | |
well... that makes a lota sense... i think i'm gonna make a separete class just for that specific object of mine... thx for the response... + bits |