Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Contributor
Posts: 47
Registered: ‎09-11-2013
My Device: different
My Carrier: wifi
Accepted Solution

Pass Values to function vs Pass Object to the function

[ Edited ]

What is the best way to pass few values to the function ?

 

Just pass the as chars or char arrays etc something like this:  function(char x, char[] z)

 

or

 

Create class(object) ..say ValuesToPass vltp;  with variables , set and get methods.

Assign values:   vltp.setX = blah, vltp.setZ = blahblah 

...  And pas vltp to the function like so:   function(vltp)    and the extract values using get methods..

 

Which way would be less time and heap space consuming?

From my point of view - passing values as values would be faster, but I'm new to java and can't be 100% sure about it..

Thanks

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Pass Values to function vs Pass Object to the function

If a method is going to working on three different bits of data, like 2 char arrays and an int, then I suspect most people would say just pass these in as parameters rather than creating a "temporary" Object just to contain these. 

Contributor
Posts: 47
Registered: ‎09-11-2013
My Device: different
My Carrier: wifi

Re: Pass Values to function vs Pass Object to the function

...and Thanks again Peter!