• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pass-by-value vs Pass-by-reference  RSS feed

 
charlie swift
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How correct is the statement "Java uses pass-by-value to send data into a method"?
Does not Java use both pass-by-value and pass-by-reference?

Thanks,
CS
 
Campbell Ritchie
Marshal
Posts: 56530
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
charlie swift wrote:. . . How correct is the statement "Java uses pass-by-value to send data into a method"?
Very correct.

Does not Java use both pass-by-value and pass-by-reference?
No. Pass by value full stop.
Thanks,
CS
That's a pleasure

I think this question might well be dupliacted in one of our other fora If you have a week to spare, try reading this thread about how not only Java®, but also cats, implement pass by value. If you haven't got that much time, try this instead.
 
charlie swift
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that's right; it indeed seems to be a duplicate thread. Sorry about that.
Guess, I should have tried to do a search here on the forum before posting my question.
Perhaps, some moderator might be able to delete this thread...
 
Paul Clapham
Sheriff
Posts: 22823
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
charlie swift wrote:Perhaps, some moderator might be able to delete this thread...


It's not a problem; another link to the FAQ entry can't hurt.
 
SunnyKumar Singh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Call-by-value and Call-by-reference or Pass-by-value and Pass-by-reference, Java only supports pass by value.
Java does not supports pass by reference.

Pass-by-value Vs Pass-by-reference

Pass-by-value - When we call a method by passing a value in method arguments is known as Pass by value.


Pass-by-reference - When we call a method by passing object reference is known as pass by value in java.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!