Строки (Java)

Материал из Информационная безопасностя
Перейти к навигации Перейти к поиску

Строки

 1 package ru.example;
 2 
 3 public class Main {
 4 
 5     public static void main(String[] args) {
 6 	    char ch = '0';
 7         System.out.printf("Char %c = %d%n", ch, (int)ch);
 8 
 9         int charCode = 55;
10         System.out.printf("Char %c = %d%n", (char)charCode, charCode);
11 
12         String str = "Hello";
13         System.out.printf("Длинна строки %s = %d%n", str, str.length());
14 
15         System.out.printf("Строка %s содержит букву l = %b%n", str, str.contains("l"));
16         System.out.printf("Строка %s содержит букву z = %b%n", str, str.contains("z"));
17 
18         System.out.printf("В строке %s индекс буквы l = %d%n", str, str.indexOf('l'));
19         System.out.printf("В строке %s индекс буквы z = %d%n", str, str.indexOf('z'));
20     }
21 }

Задачник