public Map<String, Integer> makeMap() {
Map<String, Integer> products = new HashMap<>();
products.put("가위", 2500);
products.put("크레파스", 5000);
return products;
}
@Override
public boolean equals(Object o) {
Student s = (Student) o;
return this.name.equals(s.name) && this.studentNum == s.studentNum;
}
@Override
public int hashCode() {
// int result = studentNum;
// result = 31 * result + (name != null ? name.hashCode() : 0);
// return result;
return (name + studentNum).hashCode();
}
public class Lotto {
public static void main(String[] args) {
Set<Integer> set = new HashSet<>();
while (set.size() < 6) {
int random = (int) (Math.random() * 45) + 1;
set.add(random);
}
List<Integer> list = new ArrayList<>(set);
Collections.sort(list);
System.out.println(list);
}
}
public class MyStack {
LinkedList<Integer> list;
public MyStack() {
list = new LinkedList<>();
}
public boolean empty() {
return list.size() == 0;
}
public int peek() {
return list.get(0);
}
public int pop() {
int element = list.get(0);
list.remove(0);
return element;
}
public void push(int input) {
list.add(0, input);
}
}