`cadenadni.substring(pos, pos + 1)` can be replace with `charAt(pos)`