Files
ASDV-Java/Semester 1/Assignments/lab15_CalebFontenot/src/lab15_calebfontenot/Array5.java

39 lines
1.2 KiB
Java

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package lab15_calebfontenot;
/**
*
* @author caleb
*/
public class Array5 {
public static void main(String[] args)
{
String[] alphaBetics = new String[5];
final int NAME_SIZE = 20;
//print the array that has all nulls
for (int i = 0; i < alphaBetics.length; i++) {
System.out.println(alphaBetics[i]);
}
//init the array to character numbers
for (int i = 0; i < alphaBetics.length; i++) {
alphaBetics[i] = "index " + Integer.toString(i) + " ";
}
//append to the array 20 random alphabetic characters
for (int i = 0; i < alphaBetics.length; i++) {
for (int j = 0; j < NAME_SIZE; j++) {
alphaBetics[i] += (char) (65 + Math.random() * 26);
}
}
//print the array again
for (int i = 0; i < alphaBetics.length; i++) {
System.out.println(alphaBetics[i]);
}
}
}