About 50 results
Open links in new tab
  1. java howto ArrayList push, pop, shift, and unshift

    15 maybe you want to take a look java.util.Stack class. it has push, pop methods. and implemented List interface. for shift/unshift, you can reference @Jon's answer. however, something of ArrayList you …

  2. java - Initialization of an ArrayList in one line - Stack Overflow

    Jun 17, 2009 · ArrayList<String> list = new ArrayList<String>() {{ add("A"); add("B"); add("C"); }}; However, I'm not too fond of that method because what you end up with is a subclass of ArrayList …

  3. java - How to sort a List/ArrayList? - Stack Overflow

    Apr 27, 2013 · If you want to keep the type as ArrayList<Double>, you can initialize and sort the list using the ArrayListIterate utility class as follows: ArrayList<Double> arrayList = …

  4. java - How to create a method that returns an ArrayList - Stack Overflow

    2 Create a Object of a ArrayList and pass reference to different methods. Example create a ArrayList Object in main class and pass it to addString & display method.

  5. Arraylist - Set/ add method usage - Java - Stack Overflow

    I have an Arraylist of integers. My requirement is to determine if the arraylist HAS an element existing at the specified index.If YES, then a value should be set to that index (using set method), ...

  6. java - Create ArrayList from array - Stack Overflow

    Oct 1, 2008 · If you look, Arrays ISN'T returning a true java.util.ArrayList. It's returning an inner class that implements the required methods, but you cannot change the memebers in the list.

  7. Type List vs type ArrayList in Java - Stack Overflow

    Feb 17, 2010 · Something to note is that "ArrayList specific methods" isn't limited to just methods used in ArrayList, but their return types being changed as well (will cause a NoSuchMethodException …

  8. Usage of Iteration's .hasNext(); and .next(); methods in Java

    Sep 11, 2020 · Exception in thread "main" java.util.NoSuchElementException This is the Exception. That's why hasNext () method is used as it checks whether an element is there or not. you can …

  9. java - Difference between size and length methods? - Stack Overflow

    Nov 25, 2013 · What is the difference between .size() and .length ? Is .size() only for arraylists and .length only for arrays?

  10. java - How does a ArrayList's contains () method evaluate objects ...

    375 ArrayList implements the List Interface. If you look at the Javadoc for List at the contains method you will see that it uses the equals() method to evaluate if two objects are the same.