JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

Showing posts with label ArrayList. Show all posts
Showing posts with label ArrayList. Show all posts

ArrayList in java collection with example

3:44 AM
ArrayList in java is most common Collections data structure along with  HashMap  which we use very often. Why to choose ArrayList vs Array: Array is fixed length data structure If array is full , you can not add element to it, where as ArrayList in java can dynamically grow and shrink as per our need. You can use generics with ArrayList but not with Array ArrayList have predefined methods which can be used to perform operations. Some important points about ArrayList in java are: ArrayList is implementation of list interface. ArrayList is not synchonized(so not thread safe) ArrayList is implemented using array as internal data structure.It can be dynamically resized . ArrayList increases half of its size when its size is increased. Example of ArrayList in java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30   package org . arpit . java2blog ;

.