Lesson 16 of 34

ArrayList: बढ़ने वाली List

9 min 30 XP

Array का size तय होता है। जब पता न हो कि कितने items होंगे, तो ArrayList लें, जो अपने-आप बढ़ती है। < > के अंदर int की जगह Integer और double की जगह Double लिखें।

Example: edit me and press Run

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

Example: edit me and press Run

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

Array: arr.length (brackets नहीं)। String: s.length()। ArrayList: list.size()। Interview में इन तीनों को न मिलाएँ!

Challenge

+30 XP

n और n संख्याएँ पढ़ें। सिर्फ़ सम संख्याओं को ArrayList में रखें और उसे print करें। Input: 6 1 4 7 10 12 3 Output: [4, 10, 12]

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