-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCRUD.java
More file actions
67 lines (55 loc) · 1.44 KB
/
CRUD.java
File metadata and controls
67 lines (55 loc) · 1.44 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
package Collections;
import java.util.ArrayList;
class Customer {
private int id;
private String name;
private String city;
Customer(int id, String name, String city) {
this.id = id;
this.name = name;
this.city = city;
}
public boolean equals(Object o) {
Customer c = (Customer) o;
if (this.id == c.id && this.name.equals(c.name) && this.city.equals(c.city)) {
return true;
} else {
return false;
}
}
@Override
public String toString() {
return "Customer [id=" + id + ", name=" + name + ", city=" + city + "]";
}
}
public class CRUD {
public static void main(String[] args) {
ArrayList<String> list = new ArrayList<>();
list.add("mike");
list.add("tom");
/*
* if(list.contains("mike")){ System.out.println("Mike Found..."); }
* else {
*
* System.out.println("Not Found.."); }
*/
// System.out.println(list);
String a = "Hello";
System.out.println(a.toString());
System.out.println(a);
ArrayList<Customer> customerList = new ArrayList<>();
Customer mike = new Customer(1001, "Mike", "LA");
// System.out.println(mike.toString());
// System.out.println(mike);
customerList.add(mike);
Customer tom = new Customer(1002, "Tom", "NY");
customerList.add(tom);
System.out.println(customerList);
Customer searchCustomer = new Customer(0, "Tom", null);
if (customerList.contains(searchCustomer)) {
System.out.println("Found..");
} else {
System.out.println("Not Found..");
}
}
}