Dynamic list example
Ngày đăng:
09/02/2022
Trả lời:
0
Lượt xem:
78
In the previous tutorial we have seen a static list declaration and usage with different types of data types.Now in this part of the tutorial we will get to know a dynamic list. Java Dynamic List :When we create any real time application like shopping app where cart is designed or storing users as contacts or fetching data from databases we use list. And now we cant assess the list size so we need to use java dynamic lists to fulfill the requirement. Initialize a list Now we will try to add 10 Strings into the Array List here there is no limit of Strings we can add more than 10 String too. list.add("One"); list.add("Two"); . . . . list.add("Ten");Using a for loop we can parse the loop based on the index position for(int i = 0; i < list.size(); i++){ System.out.println(list.get(i)); }String Array List:Integer Array List:ArrayListAdd numbers Share on: WhatsApp |