okay i have question about how to apply those to my code.
first the Hashmap, i used the code it and i entered information inside
dic.put(studentName, new Student( studentName, studentSurname, studentSubject, daysBookBorrowed, booksName));
this is what i put inside. now i want to extract studentName , i want the user to type the name , and the object type should be retrieved. i tried to use containsKey, but it doesnt work well.
System.out.println("Whose data do you want to look at?");
studentName=console.readLine();
for(int i=0;i<dic.size();i++){
if(dic.containsKey(book.studentName)){
System.out.println(dic.get(book));
}
}
The other question which i have:
i made a linked list with nodes in that array, and i want to sort the nodes using comparator<> interface (e.g. by name..) is it possible?
i have a comparator function.. in the class:
class Facebookfriends{
Facebookfriends info;
String name;
int age;
Facebookfriends next;
public Facebookfriends(String studentName,int age) {
super();
this.name = name;
this.age = age;
}
public int compareTo(Facebookfriends another) {
return this.name.compareTo(another.name);
}
}