Lesson 33 of 34

Sorting, Comparators এবং Lambdas

10 min 35 XP

Collections.sort() সংখ্যা ও Strings sort করে। Objects sort করতে Comparator লাগে। (a, b) -> ...-এর মতো lambda এক লাইনে একটি ছোট method লেখে।

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Streams দিয়ে কয়েক শব্দেই collections filter ও transform করা যায়। আধুনিক Java interview-এ এগুলো নিয়ে প্রায়ই প্রশ্ন আসে।

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Challenge

+35 XP

n পড়ুন, তারপর name ও score-এর n-টি লাইন। score অনুযায়ী, সবচেয়ে বেশি আগে, print করুন; সমান score হলে name অনুযায়ী A থেকে Z। Input: 3 Ram 80 Asha 95 Bala 80 Output: Asha 95 Bala 80 Ram 80

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.