06 arrays

217 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
217
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

06 arrays

  1. 1. Arrays<br />DhrubojyotiKayal<br />
  2. 2. What are arrays?<br />Declare array<br />Play with array<br />Agenda<br />
  3. 3. Container for holding multiple data elements – primitives or object together<br />Efficiently store and randomly access data elements<br />Arrays in Java are first class objects<br />Fixed size once created<br />Can only store data elements of only one kind<br />Accessed with index<br />Index starts at 0 and ends at size – 1<br />Array size is given by a special field called length<br />What are arrays?<br />
  4. 4. int a [] = newint[3];<br />int b[] = {1,2,3,4};<br />long c [] = new long[12];<br />Integer d[] = new Integer[4];<br />All one dimensional arrays<br />Declare array<br />
  5. 5. a[0] = 1, a[1] = 2, a[2] = 3;<br />System.out.println(b[2]);<br />System.out.println(b.length);<br />d[0] = new Integer(5);<br />d[1] = new Integer(88);<br />Traversing array<br />Next Session<br />Play with array<br />
  6. 6. Q&A<br />

×