Interface Mirror

Proper Solutions to Software Development Problems

  Home  |   Contact  |   Syndication    |   Login
  18 Posts | 8 Stories | 16 Comments | 1 Trackbacks

News



Article Categories

Archives

Post Categories

Link

Hi,

I started proper programming with Java in 2001 and since then I was knew that Java is a language that has "Pass by value" for primitives and "Pass by reference" for the non-primitive types. I left programming in Java in 2004 and started using C#. Since last few months again I started part time development in J2ME and last week I came across a very interesting thing. I was sending a byte array as a parameter to a method and expecting to get the same parameter as an initialized array but I don't know why I could not get desired output. Then suddenly it came in my mind to try re-factor the method to a method without parameter and just return the byte array from it. Bingo! I got the result but it took 2 hours of my time to realize the in J2ME don't have anything called "Pass By Reference". Well, I don't know the reason but there must be some design considerations. Today when I was searching the same I came to the point that "Java is Pass-by-Value". I don't know when this has happened but as far as I remember it was pass-by-reference for objects. Well, Let me know if you somewhere I am mistaken.
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Tuesday, July 29, 2008 10:19 AM