The Artima Developer Community
Sponsored Link

Java Answers Forum
call by value???

2 replies on 1 page. Most recent reply: Feb 5, 2004 10:39 PM by mahashankar sarangapani

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
black

Posts: 2
Nickname: blackscorp
Registered: Jan, 2004

call by value??? Posted: Jan 25, 2004 6:42 AM
Reply to this message Reply
Advertisement
from my tiny expierience, java passes arguments with reference.Can i call a methode by value? i want to pass an object to a methode without the methode changing it.


MRoss

Posts: 2
Nickname: mross
Registered: Jan, 2004

Re: call by value??? Posted: Jan 25, 2004 3:01 PM
Reply to this message Reply
Java actually passes parameters by value. If you pass an object reference, a local copy of the reference is created but it refers to the same object. So if you want manipulate an object in a method without changing the original, you must make a local copy first by using the clone() method or whatever.

mahashankar sarangapani

Posts: 7
Nickname: greatmaha
Registered: Feb, 2004

Re: call by value??? Posted: Feb 5, 2004 10:39 PM
Reply to this message Reply
hi!
the only way to pass object to method by call by value is
you need to make a deep clone of the object.This will not affect original one.

Flat View: This topic has 2 replies on 1 page
Topic: can't resolve symbol Previous Topic   Next Topic Topic: A drawingprogram

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use