package pl.am.podstawy.lekcja13;
public class TypString {
public static void main(String[] args) {
System.out.println("Zażółć gęślą jaźń");
System.out.println("α");
System.out.println("cytat: \"będzie dobrze\"");
System.out.println("\ttabulacja");
System.out.println("każde\nsłowo\nw\nnowej\nlini");
String pi = "\u03C0";
System.out.println(pi);
String zdanie = "Ala ma kota";
System.out.println(zdanie);
System.out.println(zdanie.substring(3));
String noweZdanie = zdanie.substring(3, 9);
System.out.println(noweZdanie);
//zdanie = zdanie.substring(3, 9);
System.out.println(zdanie);
System.out.println(noweZdanie.length());
System.out.println(zdanie.length());
System.out.println(zdanie.indexOf("ma"));
System.out.println(zdanie.indexOf("hej"));
System.out.println(zdanie.indexOf("a"));
System.out.println(zdanie.lastIndexOf("a"));
System.out.println(zdanie.toLowerCase());
System.out.println(zdanie.toUpperCase());
System.out.println(pi.toUpperCase());
System.out.println(zdanie.startsWith("Ala"));
System.out.println(zdanie.startsWith("Ela"));
System.out.println(zdanie.endsWith("kota"));
System.out.println(zdanie.endsWith("psa"));
String[] tablicaStringow = zdanie.split(" ");
System.out.println(tablicaStringow.length);
for (int i=0; i<tablicaStringow.length; i++) {
System.out.println(tablicaStringow[i]);
}
System.out.println(String.join(", ", "kot", "pies", "lama"));
System.out.println(String.join(", ", tablicaStringow));
System.out.println(zdanie.charAt(0));
System.out.println(zdanie.charAt(7));
System.out.println(zdanie.replace("Ala", "Weronika"));
System.out.println(zdanie.replace("a", ""));
System.out.println(" białe znaki ");
System.out.println(" białe znaki ".trim());
System.out.println("pierwszy" + " drugi");
System.out.println(1 + pi);
System.out.println("1" + "1");
System.out.println("1" + 1);
System.out.println(1 + "1");
System.out.println(1 + 1 + "1");
System.out.println("1" + 1 + 1);
System.out.println("xd".equals("XD"));
System.out.println("xd".equalsIgnoreCase("XD"));
String niestandardowyZnak = "\uD835\uDFD9";
System.out.println(niestandardowyZnak);
System.out.println(niestandardowyZnak.length());
}
}
package pl.am.podstawy.lekcja13;
public class Odwroc {
public static String odwroc(String tekst) {
String wynik = "";
for (int i=tekst.length()-1; i>=0; i--) {
wynik += tekst.charAt(i);
}
return wynik;
}
public static void main(String[] args) {
System.out.println(odwroc("Ala ma kota"));
}
}