ArrayList.ensureCapacity()

ArrayList

ArrayList.ensureCapacity(int minimumCapacity) Ensure Minimum capacity of elements for the ArrayList.
int minimumCapacity : Required, Integer , Minimum capacity to ensure.

add()
Examples with output
ArrayList<Integer> marks = new ArrayList<Integer>(3);
marks.add(55);
marks.add(54);
marks.add(60);
marks.ensureCapacity(8);
marks.add(61);
marks.add(62);
System.out.println(marks); //[55, 54, 60, 61, 62]
Example with string
ArrayList<String> languages = new ArrayList<String>(3);
languages.add("Java");
languages.add("PHP");
languages.add("Python");
System.out.println(languages); //[Java, PHP, Python]
languages.ensureCapacity(5);
languages.add("HTML");

System.out.println(languages); //[Java, PHP, Python, HTML]
ArrayList Tutorials



plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer