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 interviews में इनके बारे में अक्सर पूछा जाता है।

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.