I'm looking for a way to ignore an index of a vector after going through it 2 times; I have a mono-alphabetic encryption program and for that I need to cut Arrays in a certain order, the problem is that when putting 27 letters of the alphabet in an array the size of a keyword, for example "KEY", the array looks like this:
- AND Z
- STUWX
- ÑOPQR
- IJKMN
- BDFGH
- KEY CODE
so the first two letters come out of a normal array , I need to vertically extract the characters EJ:(YSÑIBC) from the entire array, but when I reach space 2 of the vector [0] it explodes because I'm using .substring() and it can't cut the void obviously; my idea is to tell my While to first start saving from index 0 forward and when there is no longer "the one to cut into vector[0]" to start with vector[1] forward ignoring 0 completely.
int puntero = 0;
int punta = 0;
while(punta < tamaño) {
while(puntero < finalArray.length){
finalStr = finalStr + String.valueOf(finalArray[puntero]).substring(punta,punta+1);
//El 2 dentro del If indica cuantas letras sobra para luego de guardarlas ignorar el vector[0]
if(punta < 2){
//
//CUANDO SE CUMPLE LA CONDICIÓN COMIENZA A IGNORAR AL 0 HASTA TERMINAR LOS DOS WHILES
//
}else{}
}
punta++;
puntero = 0;
}
System.out.println("\n");
System.out.println("FINAL: " + finalStr + " " + finalStr.length());
HERE I WILL LEAVE A MORE VISUAL WAY TO SEE WHAT I WANT TO DO: (The matrix is shorter is just for the example)
String finalStr = "";
finalStr = finalStr + String.valueOf(finalArray[0]).substring(0,1);
finalStr = finalStr + String.valueOf(finalArray[1]).substring(0,1);
finalStr = finalStr + String.valueOf(finalArray[2]).substring(0,1);
finalStr = finalStr + String.valueOf(finalArray[0]).substring(1,2);
finalStr = finalStr + String.valueOf(finalArray[1]).substring(1,2);
finalStr = finalStr + String.valueOf(finalArray[2]).substring(1,2);
//finalStr = finalStr + String.valueOf(finalArray[0]).substring(1,2); <-- LO DEBERÍA IGNORA POR INEXISTENCIA DE CARACTERES
finalStr = finalStr + String.valueOf(finalArray[1]).substring(2,3);
finalStr = finalStr + String.valueOf(finalArray[2]).substring(2,3);
//finalStr = finalStr + String.valueOf(finalArray[0]).substring(1,2); <-- X LO DEBERÍA IGNORA POR INEXISTENCIA DE CARACTERES
finalStr = finalStr + String.valueOf(finalArray[1]).substring(3,4);
finalStr = finalStr + String.valueOf(finalArray[2]).substring(3,4);
divide and conquer
If at index 0 you are going to obtain a dimension that is different from the others, you could work with it first and then with the rest.
Output execution