Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create Array and ArrayList in Java
    text
    copied!<p>I need to make an array and add and delete from the end of the array.<br> The problem is I'v been asked to build Arraylist constructor to intialize the Array "list" but I got error on that What Should I Do ??!!!</p> <p><strong>01. Creating an instance of ArrayList(‐1). The list size will become 10<br> 02. Adding 15 items. Only 10 will be added<br> 03. Here is the list<br> A C E G I K M O Q S<br> 04. Calling delete three times<br> 05. Here is the list<br> A C E G I K M<br> 06. Calling expandByTen<br> 07. Here is the list<br> A C E G I K M<br> 08. Adding 15 items.<br> 09. Here is the list<br> A C E G I K M B D F H J L N P R T V X Z</strong> </p> <pre><code>import java.util.ArrayList; public class Main{ /** * @param args */ // create an array list char []list; int length; ArrayList(int maxSize) { if (maxSize&lt;=0) length=10; else length=maxSize; } public static void main(String[] args) { // TODO Auto-generated method stub ArrayList arrayList; System.out.println("01. Creating an instance of ArrayList(‐1). The list size will become 10"); arrayList = new ArrayList(‐1); System.out.println("02. Adding 15 items. Only 10 will be added"); for (int i = 65; i &lt; 96; i += 2) { arrayList.insertEnd((char) i); } System.out.println("03. Here is the list"); arrayList.print(); System.out.println("04. Calling delete three times"); arrayList.deleteEnd(); arrayList.deleteEnd(); arrayList.deleteEnd(); System.out.println("05. Here is the list"); arrayList.print(); System.out.println("06. Calling expandByTen"); arrayList.expandByTen(); System.out.println("07. Here is the list"); arrayList.print(); System.out.println("08. Adding 15 items."); for (int i = 66; i `enter code here`&lt; 97; i += 2) { arrayList.insertEnd((char) i); } System.out.println("09. Here is the list"); arrayList.print(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload