File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # 1. toUpperCase
2+
3+ ** Что делает:**
4+ Переводит строку "Hello world" в верхний регистр (заглавные буквы).
5+
6+ ** Код:**
7+ ``` java
8+ public static void main(String [] args) {
9+ String str1 = " Hello world" ;
10+ System . out. println(loop(str1));
11+ }
12+
13+ public static String loop(String str1) {
14+ return str1. toUpperCase();
15+ }
16+ ```
17+ #### Пример вывода в консоли:
18+
19+ HELLO WORLD
20+
21+ ---
22+
23+ ### Мои заметки:
24+ - ` toUpperCase() ` — все буквы становятся заглавными
25+ - Русские буквы тоже работают: "привет" → "ПРИВЕТ"
26+ - Оригинальная строка не меняется (строки в Java неизменяемы)
27+
28+ ---
29+
30+ # 2. toLowerCase
31+
32+ ** Что делает:**
33+
34+ Переводит строку "HELLO WORLD" в нижний регистр (строчные буквы).
35+
36+ ** Код:**
37+ ``` java
38+ public static void main(String [] args) {
39+ String str1 = " HELLO WORLD" ;
40+ System . out. println(loop(str1));
41+ }
42+
43+ public static String loop(String str1) {
44+ return str1. toLowerCase();
45+ }
46+ ```
47+ #### Пример вывода в консоли:
48+
49+ hello world
50+
51+ ---
52+
53+ ### Мои заметки:
54+ - ` toLowerCase() ` — все буквы становятся строчными
55+ - Полезно для сравнения строк без учёта регистра
56+ - Оригинальная строка остаётся неизменной
You can’t perform that action at this time.
0 commit comments