-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClasses007.java
More file actions
48 lines (38 loc) · 1.35 KB
/
Copy pathClasses007.java
File metadata and controls
48 lines (38 loc) · 1.35 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
package classesIntro;
/**
* Created by WERT on 13.01.2017.
*/
public class Classes007 {
static void сhange(int i) {
System.out.println("В методе change");
i = 5;
}
static void сhange(Box b) {
System.out.println("В методе change");
b.setData("BOX1");
}
static void chnge(Box b) {
System.out.println("В методе chhge");
b = new Box();
b.setData("NEW BOX");
}
public static void main(String[] args) {
// примеры передачи аргументов в методы
int a = 10;
System.out.println("До вызова метода a = " + a);
сhange(a);
System.out.println("После вызова метода a = " + a);
System.out.println();
Box box1 = new Box();
box1.setData("box1");
System.out.println("До вызова метода box1.label = " + box1.label);
сhange(box1);
System.out.println("После вызова метода box1.label = " + box1.label);
System.out.println();
Box box2 = new Box();
box2.setData("box2");
System.out.println("До вызова метода box2.label = " + box2.label);
chnge(box2);
System.out.println("После вызова метода box2.label = " + box2.label);
}
}