Lec 2.1 Loops+Arrays
Lec 2.1 Loops+Arrays
for(int x : numbers ) {
System.out.print( x );
System.out.print(",");
}
System.out.print("\n");
String [] names = {"James", "Larry", "Tom", "Lacy"};
while( x < 20 ) {
System.out.print("value of x : " + x );
x++;
System.out.print("\n");
}
}
}
========================================================
do while loop in java
public class Test {
do {
System.out.print("value of x : " + x );
x++;
System.out.print("\n");
}while( x < 20 );
}
}
===========================================================
scanner input in the Array
package javaapplication10;
import java.util.Scanner;
a[i] = input.nextInt();
}
System.out.println("Numbers are");
System.out.println(a[i]);
}
}
}
==================================================================
scanner input in 2-D Array
public static void main(String[] args) {
{
a[i][j] = input.nextInt();
}
System.out.println("Numbers are");
System.out.println(a[i][j]);
}
}
}