-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClase Java 4.java
More file actions
62 lines (33 loc) · 1.56 KB
/
Clase Java 4.java
File metadata and controls
62 lines (33 loc) · 1.56 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
package clase.java.pkg4;
public class ClaseJava4 {
//Method
//Solo se pueden declarar dentro de una clase.
static void method(){
System.out.println("\nEsto es un metodo.");
}
//-----------------------------------------------------------------------------
static void method2(String nombre, int edad){
System.out.println("\nMi nombre es " + nombre + ".");
System.out.println("\nTengo "+ edad + " anos.");
}
//-----------------------------------------------------------------------------
static int method3(int x, int y) {
return x + y; //10 + 5
}
//-----------------------------------------------------------------------------
static float method4(float x, float y) {
return x + y;
}
//-----------------------------------------------------------------------------
static double method5(double x, double y) {
return x + y;
}
//-----------------------------------------------------------------------------
public static void main(String[] args) {
method(); //con esto llamas al method.
method2("Enrique",20);
System.out.println("\n10 + 5 =" + method3(10, 5));
System.out.println("Precio: " + method4(23.4f, 20.2f) + " euros");
System.out.println("Precio2: " + method5(10.23, 5.4)+ " euros");
}
}