public class ChangeTest {
int d=0;
char[ ] cA = { 'a' , 'b'};
public void m1(){
m2(d, cA);
System.out.println( d + ", " + cA[1] );
}
public void m2(int c, char[ ] cA2){
//
c = 2;
cA2[1] = cA2[0] = 'm';
}
public static void main(String args[]){
new ChangeTest().m1();
}
}
//Output 0, m
why the value of "d" not change?
About Question enthuware.ocajp.i.v7.2.1252 :
Moderators: Site Manager, fjwalraven
-
- Posts: 3
- Joined: Thu Jan 02, 2014 12:52 pm
- Contact:
-
- Site Admin
- Posts: 10389
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1252 :
Why do you think it should change?
-
- Posts: 5
- Joined: Thu Apr 03, 2014 3:50 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1252 :
There is a typo in the question's code. In the answers 3, 4 and 5 a space is clearly visible before the comma
while in the code, there is not:
Code: Select all
0 , m
b , b
b , m
Code: Select all
System.out.println( ( (int)c) + ", " + cA[1] );
-
- Site Admin
- Posts: 10389
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1252 :
Fixed.
thank you for your feedback!
thank you for your feedback!
Who is online
Users browsing this forum: No registered users and 7 guests