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

Más contenido relacionado

Destacado

04 data types & variables
04   data types & variables04   data types & variables
04 data types & variablesdhrubo kayal
 
03 hello world with java
03   hello world with java03   hello world with java
03 hello world with javadhrubo kayal
 
02 up close with servlets
02 up close with servlets02 up close with servlets
02 up close with servletsdhrubo kayal
 
Fitness Effect
Fitness EffectFitness Effect
Fitness Effectltaigner
 
Trabajo sergio,manuel,laura ycarolina
Trabajo sergio,manuel,laura ycarolina Trabajo sergio,manuel,laura ycarolina
Trabajo sergio,manuel,laura ycarolina Domingo Naranjo Montes
 
01 session tracking
01   session tracking01   session tracking
01 session trackingdhrubo kayal
 
C4021 Séance 8: Réseaux Sociaux
C4021 Séance 8: Réseaux SociauxC4021 Séance 8: Réseaux Sociaux
C4021 Séance 8: Réseaux SociauxAlexandru Panican
 
Optimisation SEO
Optimisation SEOOptimisation SEO
Optimisation SEOohmyweb!
 
LA COMMUNICATION 2.0 & LES MARQUES D’ALCOOL : UN COCKTAIL DÉTONANT
LA COMMUNICATION 2.0 & LES MARQUES D’ALCOOL : UN COCKTAIL DÉTONANTLA COMMUNICATION 2.0 & LES MARQUES D’ALCOOL : UN COCKTAIL DÉTONANT
LA COMMUNICATION 2.0 & LES MARQUES D’ALCOOL : UN COCKTAIL DÉTONANTNathalie Hebeisen
 

Destacado (15)

04 data types & variables
04   data types & variables04   data types & variables
04 data types & variables
 
03 hello world with java
03   hello world with java03   hello world with java
03 hello world with java
 
02 up close with servlets
02 up close with servlets02 up close with servlets
02 up close with servlets
 
01 handshake
01   handshake01   handshake
01 handshake
 
02 what is java
02   what is java02   what is java
02 what is java
 
17 exceptions
17   exceptions17   exceptions
17 exceptions
 
Fitness Effect
Fitness EffectFitness Effect
Fitness Effect
 
Trabajo sergio,manuel,laura ycarolina
Trabajo sergio,manuel,laura ycarolina Trabajo sergio,manuel,laura ycarolina
Trabajo sergio,manuel,laura ycarolina
 
Week1
Week1Week1
Week1
 
11 static
11   static11   static
11 static
 
01 session tracking
01   session tracking01   session tracking
01 session tracking
 
frankrijk.nl
frankrijk.nl frankrijk.nl
frankrijk.nl
 
C4021 Séance 8: Réseaux Sociaux
C4021 Séance 8: Réseaux SociauxC4021 Séance 8: Réseaux Sociaux
C4021 Séance 8: Réseaux Sociaux
 
Optimisation SEO
Optimisation SEOOptimisation SEO
Optimisation SEO
 
LA COMMUNICATION 2.0 & LES MARQUES D’ALCOOL : UN COCKTAIL DÉTONANT
LA COMMUNICATION 2.0 & LES MARQUES D’ALCOOL : UN COCKTAIL DÉTONANTLA COMMUNICATION 2.0 & LES MARQUES D’ALCOOL : UN COCKTAIL DÉTONANT
LA COMMUNICATION 2.0 & LES MARQUES D’ALCOOL : UN COCKTAIL DÉTONANT
 

Más de dhrubo kayal

01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setupdhrubo kayal
 
14 initialization & cleanup
14   initialization & cleanup14   initialization & cleanup
14 initialization & cleanupdhrubo kayal
 

Más de dhrubo kayal (9)

Cipla 20-09-2010
Cipla   20-09-2010Cipla   20-09-2010
Cipla 20-09-2010
 
01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup
 
19 reflection
19   reflection19   reflection
19 reflection
 
18 concurrency
18   concurrency18   concurrency
18 concurrency
 
15 interfaces
15   interfaces15   interfaces
15 interfaces
 
14 initialization & cleanup
14   initialization & cleanup14   initialization & cleanup
14 initialization & cleanup
 
13 inheritance
13   inheritance13   inheritance
13 inheritance
 
12 encapsulation
12   encapsulation12   encapsulation
12 encapsulation
 
05 operators
05   operators05   operators
05 operators
 

06 arrays

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