Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

iterator for array java

import java.util.Arrays;
import java.util.Iterator;

public class ArrayToIterable {
   public static void main(String args[]){
      Integer[] myArray = {897, 56, 78, 90, 12, 123, 75};
      Iterator<Integer> iterator = Arrays.stream(myArray).iterator();
      while(iterator.hasNext()) {
         System.out.println(iterator.next());
      }
   }
}
Comment

For loop Java Example to Iterate an Array

class Main {
    public static void main(String args[]){
         int arr[]={1,2,3,4,5};
         //i starts with 0 as array index starts with 0 too
         for(int i=0; i<arr.length; i++){
              System.out.println(arr[i]);
         }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to create immutable list java 
Java :: counting sort java 
Java :: Display double in decimal places java 
Java :: java import joptionpane 
Java :: java how to make a gui 
Java :: java compare strings alphabetically 
Java :: capitalize string java 
Java :: java print two dimensional array 
Java :: creating array java 
Java :: java get input 
Java :: font parameters java 
Java :: java factorial loop 
Java :: java resource file 
Java :: java 8 functional interfaces 
Java :: write json file java 
Java :: Char in scanner 
Java :: read json file java 
Java :: declare array with values java 
Java :: android recyclerview show hide item with animation with default animation 
Java :: java loop hashmap 
Java :: open gallery android 
Java :: java encrypt string 
Java :: java check if enum contains value 
Java :: parse string to int java 
Java :: how to change label text color javafx 
Java :: javafx resizable window 
Java :: how to create relative layout in android studio 
Java :: convert base64 to image png without saving 
Java :: flow dependency android 
Java :: instantiate optinal java 8 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =