Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions modules/35-methods-using/115-string-immutability/App.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
public class App {
public static void main(String[] args) {
var email = " SupporT@hexlet.io\n";
var email = "\tSupporT@hexlet.io ";

// BEGIN
email = email.trim();
email = email.toLowerCase();
System.out.println(email);
System.out.println(email.trim().toLowerCase());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так, а теперь получается нет разницы с тем, что было раньше.
Только если обратите внимание, то мы ранее перезаписывали еременную, тк цепочку методов изучаем в след уроке.

// END
}
}
7 changes: 6 additions & 1 deletion modules/35-methods-using/115-string-immutability/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ public static void main(String[] args) {

App.main(null);

final var actual = out.toString().trim();
String answer = out.toString();
if (answer != null && answer.endsWith("\n")) {
// remove linefeed added by println
answer = answer.substring(0, answer.length() - 1);
}
final var actual = answer;

System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
System.out.println(actual);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@
* Удаление концевых пробельных символов с помощью метода `.trim()`, например, было: `" hexlet\n "`, стало: `"hexlet"`
* Приведение к нижнему регистру с помощью метода `toLowerCase()`. Было: `"[email protected]"`, стало: `"[email protected]"`.

Обновите переменную `email` записав в неё то же самое значение, но обработанное по схеме указанной выше. Распечатайте то, что получилось, на экран.
Напишите метод `normalize()`
```
public static final String email = " [email protected]\n";
public static String normalize() {
...
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь осталось про метод normalize

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вернул обратно как было. Да, теперь получается нет разницы с тем, что было раньше, за исключением теста. Причина бага как раз в нем

Обновите переменную email записав в неё то же самое значение, но обработанное по схеме указанной выше. Распечатайте то, что получилось, на экран.