I am making a random password Generator and want to add an array value to another array "pa" in order to make a single string password. Any help would be appreciated.
package project;
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.util.Random;
public class RandomPass {
public static void Randpass(){
Scanner scan = new Scanner(System.in);
Random rand = new Random();
String[] alphabet= {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
JOptionPane.showMessageDialog(null, "Welcome to RandomPassword Generator");
int c= Integer.parseInt(JOptionPane.showInputDialog(null,"How long do you want the password"));
int nc =0-c;
int c2=c/2;
int nc2= 0-c2;
int ncm =(nc+1)/2;
String pa [];
if(c%2==0){
for(int x=nc2;x<0;x++){
int alphanum =rand.nextInt(26);
pa.add(alphabet[alphanum]);
int numNum =rand.nextInt(10);
pa.add(numNum);
}
}else{
for(int x=ncm;x<0;x++){
int alphanum =rand.nextInt(26);
int numNum =rand.nextInt(10);
}
}
}
}
Collectionsand orArrays?ArrayList. Arrays have a fixed size and work with indexes.StringBuilder. Also, which version of Java is that?