-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
82 lines (68 loc) · 2.41 KB
/
Main.java
File metadata and controls
82 lines (68 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import java.util.ArrayList;
import java.util.List;
import java.lang.String;
public class Main {
public static void main(String[] args) {
int nNum1 = 12;
int nNum2 = 13;
int nNum3 = 14;
// String[] miArray = new String[10]; puede ser asi tambien pero arreglo vacio
String[] miArray = { "1", "2", "3", "4", "los", "el", "tu", "yo", "a", "b" };
List<String> miArray2 = new ArrayList<>();
miArray2.add("jose");
miArray2.add("luis");
int Resultado = Sumar( nNum1, nNum2, nNum3);
System.out.println("la suma de "+nNum1+" + "+nNum2+" + "+nNum3+" es : " + Resultado);
Coche miCoche = new Coche();
miCoche.AgregarPuerta();
System.out.println("Mostrar Objeto "+miCoche.getClass());
System.out.println("numero de puertas : " + miCoche.puertas);
recorrerWhile( nNum1 );
recorrerFor( miArray, miArray2);
}
public static int Sumar(int a, int b, int c) {
int x;
if (a > b) {
x = a + c;
}
else{
x = b + c;
}
return x;
}
public static void recorrerWhile(int nVeces){
int nContador = 1;
while (nContador <= nVeces ){
if (nContador % 2 == 0) {
System.out.println("while " + nContador + "aa");
}
nContador++;
}
}
public static void recorrerFor( String[] miArray, List<String> miArra2){
System.out.println("arreglo total posicion "+ miArray.length);
for (int pos = 0; pos < miArray.length; pos++ ) {
//for (int pos : miArray) {
// System.out.println("arreglo en posicion " +pos+ " es " + miArray[pos]);
switch (miArray[pos]) {
case "tu" -> System.out.println("eres " + miArray[pos]);
case "yo" -> System.out.println("soy " + miArray[pos]);
default -> System.out.println("los demas " + miArray[pos]);
}
switch (pos){
case 0:
System.out.println("arreglo2 " +pos+ " es " + miArra2.get(pos));
break;
case 1:
System.out.println("arreglo22 " +pos+ " es " + miArra2.get(pos) );
break;
}
}
}
}
class Coche {
public int puertas = 0;
public void AgregarPuerta() {
this.puertas++;
}
}