Complete IIT AIEEE ICSE ISC PMT help forum
This is a free help Forum for Indian Students.
Complete IIT AIEEE ICSE ISC PMT help forum

Complete help forum for students preparing for icse iit aieee cbse pmt and other related exams.Stay updated about all 2011 exams.
 
HomeHome  PortalPortal  FAQFAQ  SearchSearch  RegisterRegister  MemberlistMemberlist  UsergroupsUsergroups  Log in  India NewsIndia News  
Keywords
YEAR 2010 CLASS RESULT
Latest topics
Top posters
abhas
 
Anu..i luv icse...:)
 
G-7
 
siya
 
Candy
 
jOhNy
 
Apurva
 
WinRrule
 
ambili
 
saif
 



Search if you can't find it here

Program to explain some behaviors of an array

View previous topic View next topic Go down
AuthorMessage
saif
Active member
Active member



PostSubject: Program to explain some behaviors of an array Wed Mar 17, 2010 2:01 pm

class array_try
{
private static int arr[][]=new int[5][5];
private static int arr2[][]=new int[6][7];

public static void main(String args[])
{
System.out.println("Dsplaying details of arr[][]");
System.out.println("row="+arr.length);
System.out.println("column="+arr[0].length);
arr2[5][6]=50;
arr=arr2;
System.out.println("arr[5][6]="+arr[5][6]);
System.out.println("New row="+arr.length);
System.out.println("New column="+arr[0].length);

}
}



OUTPUT
row=5
column=5
arr[5][6]=50
New row=6
New column=7
Dsplaying details of arr[][]
row=5
column=5
arr[5][6]=50
New row=6
New column=7


CONCLUSION


you may change the array size if desired
Back to top Go down
View user profile
NITIN BHUWANIA
Active member
Active member
avatar


PostSubject: Re: Program to explain some behaviors of an array Wed Mar 17, 2010 8:47 pm

what is this for???

what do we have to do in this program??
Back to top Go down
View user profile
saif
Active member
Active member



PostSubject: Re: Program to explain some behaviors of an array Thu Mar 18, 2010 10:02 am

this program shows that you may change the array size if desired and can store the value of an array in another array by arr1=arr2
Back to top Go down
View user profile
Rabi




PostSubject: @saif Thu Mar 18, 2010 1:35 pm

hey guys dont u think..dat this logic is nt suitable
by writing arr=arr2;
u r only making the reference of arr point towards arr2
u r nt changing the array length bt u r creating two copies of same arr2 so u loose the original arr
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: Program to explain some behaviors of an array Thu Mar 18, 2010 2:20 pm

whatever...! But the point that saif wants top bring out is that arrays are mutable...!! and that it can be copied..! as he has just initialised one position to 50. So..it doesnt matter if we just copied it the ordinary way...!!
Back to top Go down
View user profile
saif
Active member
Active member



PostSubject: Re: Program to explain some behaviors of an array Thu Mar 18, 2010 2:21 pm

and yes we will loose the original array arr...
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: Program to explain some behaviors of an array Thu Mar 18, 2010 2:22 pm

saif..what is the property that u wish to present over here.?
Back to top Go down
View user profile
saif
Active member
Active member



PostSubject: Re: Program to explain some behaviors of an array Thu Mar 18, 2010 2:32 pm

you have rightly guessed.I just wanted to show that "arrays are mutable" and we can do arr1=arr2; we can do same thing with objects....
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: Program to explain some behaviors of an array Thu Mar 18, 2010 2:36 pm

yea man...good program..!
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: Program to explain some behaviors of an array

Back to top Go down

Program to explain some behaviors of an array

View previous topic View next topic Back to top
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Complete IIT AIEEE ICSE ISC PMT help forum :: ISC :: ISC 2010 [Class xii] :: Computer-