i have char[][] looks this:
| u | | e | e | b | | e | | d | | | u | | | u | e | u | t | u | o | y | | o | u | u | x | | s | o | o | u | e | | o | | o | u | w | | o | | | u | | o | u | y | c | | x | | u | w | w | | | o | | | | | u | h | o | u | | f | x | v | u | g | | e | | p | | | | u | m | | u | o | u | e | b | o | | t | o | o | e | u | | | e | | | | t | | f | c | m | g | p | z | o | j |
then if introduce word (for example: card), want change 4 characters one: '·'. problem have delete 'c', 'a', 'r', 'd' characters of 2d array, outputing this:
| u | · | e | e | b | | e | | · | · | | u | · | · | u | e | u | t | u | o | y | | o | u | u | x | · | s | o | o | u | e | | o | · | o | u | w | · | o | · | | u | | o | u | y | · | | x | · | u | w | w | | · | o | | | · | | u | h | o | u | | f | x | v | u | g | · | e | | p | · | | | u | m | · | u | o | u | e | b | o | | t | o | o | e | u | | | e | · | | | t | · | f | · | m | g | p | z | o | j |
i want output this:
| u | · | e | e | b | | e | | · | | | u | | | u | e | u | t | u | o | y | | o | u | u | x | | s | o | o | u | e | | o | | o | u | w | | o | | | u | | o | u | y | · | | x | | u | w | w | | | o | | | | | u | h | o | u | | f | x | v | u | g | | e | | p | | | | u | m | | u | o | u | e | b | o | | t | o | o | e | u | | | e | | | | t | | f | c | m | g | p | z | o | j |
thanks.
put character
s want delete in arraylist
, remove them list if have found , matching char
in char[][]
. it's not perfect start can do:
arraylist<character> mylist = new arraylist<>(arrays.aslist('c','a','r','d')); char[][] myarray = new char[/*todo size*/][/*todo size*/]; outerloop: for(int =0; < myarray.length; i++){ for(int j =0; j < myarray[i].length; j++){ if(mylist.contains(myarray[i][j])){ mylist.remove(myarray[i][j]); myarray[i][j] = '.'; if(mylist.isempty()){ break outerloop; } } } }
Comments
Post a Comment