Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

iterator java

// Import the ArrayList class and the Iterator class
import java.util.ArrayList;
import java.util.Iterator;

public class Main {
  public static void main(String[] args) {

    // Make a collection
    ArrayList<String> cars = new ArrayList<String>();
    cars.add("Volvo");
    cars.add("BMW");
    cars.add("Ford");
    cars.add("Mazda");

    // Get the iterator
    Iterator<String> it = cars.iterator();

    // Print the elements in the list
    while(it.hasNext()){
    System.out.println(it.next());
    }
  }
Comment

iterator java8

//Stream.iterate(initial value, next value)
	Stream.iterate(0, n -> n + 1)
                .limit(10)
                .forEach(x -> System.out.println(x));
Comment

PREVIOUS NEXT
Code Example
Java :: android stop audio playing by activity lifecycle 
Java :: Calculator repeat 
Java :: polymorphism array with abstract class java 
Java :: java %2C 
Java :: bloomreach clone session 
Java :: guava-18.0.jar 
Java :: java compareto jdei stackoverflow 
Java :: return string consistent of n lowercase letters such is all letters occurs an odd number 
Java :: time complexity of indexof java 
Java :: springBoot Register a Custom Auto-Configuration 
Java :: how to switch between two stylesheets in javafx. 
Java :: how to cut a certion part from a string in java 
Java :: Performance data in appium 
Java :: find maximum number of rides in amusement park python 
Java :: android int color = ContextCompat.getColor(getContext(), mColorResourceId); 
Java :: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type project and qualifiers [@Default] 
Java :: Creating strings using the new keyword Java 
Java :: how to get data from array list to set java 
Java :: how to set to nothing a ComboBox in java 
Java :: spigot deal damage 
Java :: Java Method Overloading by changing the data type of parameters 
Java :: Spring security avec spring version 2.5.6 
Java :: how to use old android studio project 
Java :: calculate values of array 
Java :: JSP Redirigir a otra página 
Java :: before first in jdbc 
Java :: how to get visibility of element android 
Java :: maximum valid parentheses 
Java :: reading data from wsdl in java 
Java :: spinner get items 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =