Advertisement
cesarnascimento

for each loiane nums aleatorios

Aug 17th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. package foreach.aula21;
  2.  
  3. import java.util.Random;
  4.  
  5. public class foreach {
  6.  
  7.     public static void main(String[] args) {
  8.         int [] notas = new int[10];
  9.        
  10.         Random random = new Random();
  11.        
  12.         for(int i = 0; i<notas.length; i++){
  13.             notas[i] = random.nextInt(10);
  14.         }
  15.        
  16.         for(int i = 0; i<notas.length;i++){
  17.             int nota = notas[i];
  18.             System.out.println(notas[i]);
  19.         }
  20.        
  21.        
  22.         System.out.println("usando for each");
  23.        
  24.         for(int nota : notas){
  25.             System.out.println(nota);
  26.         }
  27.     }
  28.     /* César N. */
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement