58 lines
1.7 KiB
Java
58 lines
1.7 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 Array6 {
|
|
|
|
public static void main(String[] args)
|
|
{
|
|
String[] alphaBetics = new String[10];
|
|
final int NAME_SIZE = 3;
|
|
/*
|
|
//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] = "";
|
|
}
|
|
|
|
//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) (97 + Math.random() * 26);
|
|
}
|
|
}
|
|
//print the array
|
|
for (int i = 0; i < alphaBetics.length; i++) {
|
|
System.out.println(alphaBetics[i]);
|
|
|
|
}
|
|
System.out.println();
|
|
// Reverse each string in the array
|
|
String tmp = "";
|
|
for (int i = 0; i < alphaBetics.length; i++) {
|
|
tmp = "";
|
|
int stringLength = alphaBetics[i].length();
|
|
for (int j = 0; j < stringLength; j++) {
|
|
char currentChar = alphaBetics[i].charAt(j);
|
|
tmp = currentChar + tmp;
|
|
}
|
|
alphaBetics[i] = tmp;
|
|
}
|
|
for (int i = 0; i < alphaBetics.length; i++) {
|
|
System.out.println(alphaBetics[i]);
|
|
|
|
}
|
|
}
|
|
}
|
|
|