package ru.topjava.string;
public class StringRepeat {
public static void main(String[] args) {
String strRepeat = "Knock ".repeat(2);
System.out.println(strRepeat); // "Knock Knock "
System.out.println(strRepeat.equals("Knock Knock ")); // true
}
}
package ru.topjava.string;
public class StringStrip {
public static void main(String[] args) {
String strStrip = "\u2006 java \n \t".strip();
System.out.println(strStrip); // "java"
System.out.println(strStrip.equals("java")); // true
}
}
package ru.topjava.string;
public class StringTrim {
public static void main(String[] args) {
String strTrim = "\u2006 java \n \t".trim();
System.out.println(strTrim); // " java"
System.out.println(strTrim.equals("java")); // false
}
}
package ru.topjava.string;
public class StringIsBlank {
public static void main(String[] args) {
String strIsBlank = "\u2006 \n \t";
String strEmpty = "";
System.out.println(strIsBlank.isBlank()); // true
System.out.println(strEmpty.isBlank()); // true
}
}
package ru.topjava.string;
public class StringLines {
public static void main(String[] args) {
String str = "Write \n once, \nrun anywhere\n (WORA)";
str.lines().map(String::strip).forEach(System.out::println);
}
}