Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class untitled {
- public static void main (String[] args) {
- String [] name = new String[] {"retw","rqu","wert","r","asd"};
- String[] alphabet = new String[]{"q","w","e","r","t","y","u","i","o","p","a","s","d"};
- String[] newName = new String[name.length];
- int g = 0;
- for (String na : name) {
- boolean flag = false;
- //for(int i = 0; i<alphabet.length; i++){
- for (String alf : alphabet) {
- if (flag) {
- break;
- }
- for (String n : na.split("")) {
- //for (int g = 0; g<name.length; g++){
- if (n.equals(alf)) {
- newName[g] = na;
- g++;
- break;
- }
- if (!n.equals(alf)) {
- flag = true;
- break;
- }
- //}
- }
- }
- }
- for (int i = 0; i< newName.length; i++)
- System.out.print(newName[i]+ " ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment