Advertisement
sergAccount

Untitled

Dec 19th, 2020
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package ja12;
  7.  
  8. /**
  9.  *
  10.  * @author Administrator
  11.  */
  12. public class JA12 {
  13.  
  14.     public static void main(String[] args) {
  15.         // TODO code application logic here
  16.         String s = "JAAAAAAAAAB ADADD";
  17.         String res = s + "!!!!";
  18.         System.out.println(res);
  19.         // метод charAt - позволяет получить по индексу определенный символ
  20.         char ch1 = s.charAt(0);
  21.         System.out.println("ch1=" + ch1);
  22.         // метод для получения длины строки
  23.         int len = s.length();
  24.         System.out.println("len=" + len);
  25.         //
  26.         String substring = s.substring(0, 3);
  27.         System.out.println("substring=" + substring);
  28.         // преобразование данных одного типа в другой
  29.         // число - значение типа int или double - выполнение преобразования в значение типа String
  30.         int i = 10;
  31.         // valueOf - статический метод класса String
  32.         String iString = String.valueOf(i);
  33.         System.out.println("iString=" + iString);
  34.         //
  35.         double d1 = 10.200;
  36.         String sString = String.valueOf(d1);
  37.         System.out.println("sString=" + sString);
  38.     }
  39.  
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement