Escolar Documentos
Profissional Documentos
Cultura Documentos
Compiladorecs
Compiladorecs
*/ package automata1; /** * * @author Pedro */ public class Automata1 { public static boolean validacion(String palabra){ int pos=0; int state=0; int tam; tam=palabra.length(); while(pos<tam){ switch(state){ case 0: switch(palabra.charAt(pos)) { case 'a': state=0; break; case 'm': state=1; break; default: return false; } break; case 1: switch(palabra.charAt(pos)) { case 'a': state=2; break; default: return false; } break; case 2: switch(palabra.charAt(pos)) { case 'm': state=3; break; default: return false; } break; case 3: switch(palabra.charAt(pos)) { case 'a': state=4; break; default:
return false; } break; } pos++; } return true; } public static void main(String[] args) { System.out.print(validacion("mama")); } }