0
Can enhanced for loop be used for initialisation? It didn't work for me......all elements got initialised with zero. ...
for(int i:arr) t=myvar.nextInt();
5 Answers
+ 1
thanks a lot!!!!
0
//this was the code
package arrays;
import java.util.Scanner;
/**
 *
 * @author gokul
 */
public class array {
    public static void main(String[] args){
        int n;
        System.out.println("enter n");
        Scanner myvar=new Scanner(System.in);
        n=myvar.nextInt();
        int arr[]= new int[n];
        
        for(int i:arr)
            i=myvar.nextInt();
        System.out.println("\n your array is ...");
        for(int t:arr)
            System.out.println("\n "+t);
}
}




