-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer.java
More file actions
43 lines (36 loc) · 1.72 KB
/
Customer.java
File metadata and controls
43 lines (36 loc) · 1.72 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
package com.tutorial.def;
public class Customer {
// The private access modifier means that
// only code inside the class itself can access this Java field.
private String email;
// The package access modifier means that only code inside the class itself,
// or other classes in the same package, can access the field.
// You don't actually write the package modifier.
// By leaving out any access modifier, the access modifier defaults to package scope.
String position; //no modiifier = 'package' access modifier
// The protected access modifier is like the package modifier,
// except subclasses of the class can also access the field,
// even if the subclass is not located in the same package.
protected String name;
// The public access modifier means that the field can be accessed by all classes in your application.
public String city;
final String str = "FINAL";
final int[] arr = {1,2,3,4,5,6};
public void changeStr(String str1, String str2){
System.out.println("changeStr():: str1 is " + str1 + ", and str2 is " + str2);
str1 = "new value 1";
str2 = "new value 2";
System.out.println("changeStr():: str1 is " + str1 + ", and str2 is " + str2);
}
public static void main(String[] args) {
Customer customer = new Customer();
System.out.println(customer.str);
System.out.println(customer.arr[1]);
customer.arr[1] = 22;
System.out.println(customer.arr[1]);
String str1 = "Old value 1";
String str2 = "Old value 2";
customer.changeStr(str1, str2);
System.out.println("main():: str1 is " + str1 + ", and str2 is " + str2);
}
}