Skip to content

Commit

Permalink
3. Тестовое задание. Блок "Базовый синтаксис";
Browse files Browse the repository at this point in the history
  • Loading branch information
Temzor committed Oct 15, 2023
1 parent 0944092 commit e4a97d6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/ru/j4j/array/SimpleStringEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ public static String encode(String input) {
if (symbol == input.charAt(i)) {
counter++;
} else {
result.append(symbol).append(counter);
symbol = input.charAt(counter);
result.append(symbol).append(counter == 1 ? "" : counter);
symbol = input.charAt(i);
counter = 1;
}
}
return result.toString();
return String.valueOf(result.append(symbol).append(counter == 1 ? "" : counter));
}
}

0 comments on commit e4a97d6

Please sign in to comment.