Ciclos en Java - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Ciclos en Java

Description:

{ algo: { switch(z[i]) { case 0: break; case 1: break algo; case 2: break ciclo; ... case 1: break algo; case 2: break ciclo; case 3: break test; case 4: continue; ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 15
Provided by: homeGa
Category:
Tags: algo | ciclos | java

less

Transcript and Presenter's Notes

Title: Ciclos en Java


1
Ciclos en Java
Ing. Andrea Quan
2
while
  • inicializacion
  • while (condicion)
  • .
  • step
  • int i 0
  • while (i lt 10)
  • System.out.println(i)
  • i

3
while
  • public static boolean esPrimo(int n)
  • int d 2
  • while (d lt n)
  • if (nd 0)
  • return false
  • d
  • return true

4
for
  • for (inicializacioncondiciónstep)
  • .
  • for (int i 0 i lt 10 i)
  • System.out.println(i)

5
for
  • public static boolean esPrimo(int n)
  • for (int d 2 d lt n d)
  • if (nd 0)
  • return false
  • return true

6
do
  • inicializacion
  • do
  • .
  • step
  • while (condición)
  • int i 0
  • do
  • System.out.println(i)
  • i
  • while (i lt 10)

7
break y continue
  • El break termina inmediatamente el ciclo o
  • switch.
  • String s br.readLine()
  • while (s.length() gt 0)
  • System.out.println(s)
  • s br.readLine()
  • --------------------------
  • while (true)
  • s br.readLine()
  • if (s.length 0) break
  • System.out.println(s)

8
break y continue
  • test
  • if (x 0)
  • ciclo
  • while (i lt 9)
  • algo
  • switch(zi)
  • case 0 break
  • case 1 break algo
  • case 2 break ciclo
  • case 3 break test
  • case 4 continue
  • default continue ciclo
  • instruccion1
  • instruccion2 i
  • instruccion3
  • instruccion4

9
break y continue
  • test
  • if (x 0)
  • ciclo
  • while (i lt 9)
  • algo
  • switch(zi)
  • case 0 break
  • case 1 break algo
  • case 2 break ciclo
  • case 3 break test
  • case 4 continue
  • default continue ciclo
  • instruccion1
  • instruccion2 i
  • instruccion3
  • instruccion4

10
break y continue
  • test
  • if (x 0)
  • ciclo
  • while (i lt 9)
  • algo
  • switch(zi)
  • case 0 break
  • case 1 break algo
  • case 2 break ciclo
  • case 3 break test
  • case 4 continue
  • default continue ciclo
  • instruccion1
  • instruccion2 i
  • instruccion3
  • instruccion4

11
break y continue
  • test
  • if (x 0)
  • ciclo
  • while (i lt 9)
  • algo
  • switch(zi)
  • case 0 break
  • case 1 break algo
  • case 2 break ciclo
  • case 3 break test
  • case 4 continue
  • default continue ciclo
  • instruccion1
  • instruccion2 i
  • instruccion3
  • instruccion4

12
break y continue
  • test
  • if (x 0)
  • ciclo
  • while (i lt 9)
  • algo
  • switch(zi)
  • case 0 break
  • case 1 break algo
  • case 2 break ciclo
  • case 3 break test
  • case 4 continue
  • default continue ciclo
  • instruccion1
  • instruccion2 i
  • instruccion3
  • instruccion4

13
break y continue
  • test
  • if (x 0)
  • ciclo
  • while (i lt 9)
  • algo
  • switch(zi)
  • case 0 break
  • case 1 break algo
  • case 2 break ciclo
  • case 3 break test
  • case 4 continue
  • default continue ciclo
  • instruccion1
  • instruccion2 i
  • instruccion3
  • instruccion4

14
Constantes
  • Una constante es aquella variable cuyo valor
  • no cambia durante todo el programa.
  • public final int FEBRERO 2
  • if (mes 2) ? if (mes FEBRERO)
Write a Comment
User Comments (0)
About PowerShow.com