Ask Experts Questions for FREE Help !
Ask
    spiderman20084's Avatar
    spiderman20084 Posts: 1, Reputation: 1
    New Member
     
    #1

    Feb 20, 2015, 01:36 PM
    I need help with pointers and passing-by-refrence
    Hello
    I've been working on a program and I've encountered a little problem
    Here is the simplest form of my problem
    Code:
    public static void main(String[] args) {		int[] a = new int[]{1,2,3};
    		trial3(a);
    	}
    	
    	private static void trial3(int[] i) {
    		int[] b = i;
    		b[1] = 0;
    		System.out.println(Arrays.toString(b)+ Arrays.toString(i));
    	}
    I expect the result would be [1, 0, 3][1, 2, 3] but instead the real result is
    [1, 0, 3][1, 0, 3]
    I don't really know why this happen could someone please explain it to me and
    Tell me a simple way to get the expected result.

Check out some similar questions!

Laser pointers and dogs [ 5 Answers ]

I have trouble getting Muttley (my Yorkie) as much exercise as he may need due to time restrictions and the weather being too hot from 10 am till after 7 or 8 pm most days to venture out. I thought if I got a laser pointer I could run him around in the apartment safely. Until now I have...

Need some pointers to get the ball rolling [ 3 Answers ]

What's better then getting straight to the point, so I will. A good friend and I drive for a small trucking company and we want more out of life than what we're getting out of it. We want to make the kind of money that we know that's out there in the trucking industry. We've got a basic plan of...

2weeks late & passing passing clots [ 1 Answers ]

My period is weeks late and yesterday I had some bad cramping. I had some light bleeding & then I passed to large clots. I have never had any clots this size before. I am still bleeding. Is this just a late period or am I having a miscarriage ?

Pointers in c [ 3 Answers ]

What is pointer


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.