Sorting Weekdays Using Java Comparator | Tricky Java Interview Questions | Coding

preview_player
Показать описание
This video contains sorting weekdays strings using java comparator, one of the tricky interview questions.

One of the best book for Interview Questions

📌 Do Subscribe for all Updates.

Telegram : Drunken Engineer

You can follow us on Facebook :

#java #comparator #sorting
Рекомендации по теме
Комментарии
Автор

public enum Weekdays {
SUNDAY(0), MONDAY(1), TUESDAY(2), WEDNESDAY(3), THURSDAY(4), FRIDAY(5), SATURDAY(6);

private Integer weekDayVal;

Weekdays(Integer weekDayVal) {
this.weekDayVal = weekDayVal;
}

public Integer getWeekDayVal() {
return this.weekDayVal;
}
}
Arrays.asList(Weekdays.MONDAY, Weekdays.SATURDAY, Weekdays.THURSDAY, Weekdays.SUNDAY).stream().sorted(Comparator.naturalOrder()).forEach(System.out::println);

pratikwankhede
Автор

It would be better if you could maintain a github repo and give that in the description.
Keep up the good work.

AdityaSharan
Автор

Hey, I tried with Switch case but no luck, its displaying same result which I passed as input. If possible could u plz share your code. It helps a lot. Thanks

odengineer
Автор

Any developers are here.please help me out from one doubt
If I locked the master branch how can you publish your code in master branch?

amanib