Java - ERROR: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 108

 
Vista:

ERROR: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 108

Publicado por luis (1 intervención) el 22/10/2017 06:34:26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import javax.swing.*;
import java.lang.*;
/**
*
* @author luishernandez
*/
public class EncripFINAL {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String abc = "abcdefghijklmnñopqrstuvwxyz1234567890+-?¿¡'(&%!|@#¬*¨_;:,.<>";
String[]abc2={"&","$","#","@","1","2","3","4","a","B","c","d","+","-","?","¿","¡","5","6","7","8","e","f","G","h","'","(","%","·","i","j","k","L","¬","*","¨","_","9","M","n","ñ","o",";",":",",",":","<",">","p","q","r","s","t","u","v","w","x","y","z","0"};
char[] texto= JOptionPane.showInputDialog("Texto: ").toLowerCase().toCharArray();
StringBuilder w=new StringBuilder(texto.length);
for(char c : texto){
int x=abc.indexOf(c);
if (c >=0){
w.append(abc2[c]);
}else{
w.append(c);
}
}
JOptionPane.showMessageDialog(null, w.toString());
}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder