I am trying to make a game for android I have a bitmap and canvas instance in my main class.
I have another instance of, lets say, renderer class. That renderer class is in the same package, but not the subclass of my main class.
If i pass the bitmap and canvas instance to a method of that renderer class and that method will draw that passed bitmap to the passed canvas, are the actual instances passed or new instance copies created and then passed ? Well, i have tried and saw that actual instances were being passed. Because i was seeing the bitmap being drawn to the canvas.
Here is my question, why are the actual instances are passed ? if it was something like this ->
public class instanceTest
{
static int num;
static void numIncrementor(int number)
{
number++;
}
public static void main(String[] args)
{
num = 0;
numIncrementor(num);
System.out.println(num);
}
}
Here, when i print the num, i will still get 0, but with other bitmap and canvas thing, i do send the actual instances. This got me really confused. Can someone explain it ? Or is it always the case with class objects unlike primitive types ? Does it make garbage collector go crazy ?
Thanks in advance, if you did not understand my engrish, tell and i will put pseudo codes here for clarification;