package tomp.ucebnice.retezce; public class HledejVyberPreved { public static void main(String[] args) { String s1 = "abcde abc a"; String s2 = "ab"; String s3 = "cde"; System.out.println(s1.startsWith(s2)); // true System.out.println(s1.indexOf(s2)); // 0 System.out.println(s1.lastIndexOf(s2)); // 6 System.out.println(s1.indexOf(s2, 1)); // 6 System.out.println(s1.substring(6, 8)); // "ab" System.out.println(s1.charAt(7)); // 'b' // převody řetězců na čísla String cele = "123"; String necele = "1.2345"; byte b = Byte.parseByte(cele); // short s = Short.parseShort(cele); int i = Integer.parseInt(cele); long l = Long.parseLong(cele); float f = Float.parseFloat(necele); double d = Double.parseDouble(necele); System.out.println(b); System.out.println(s); System.out.println(i); System.out.println(l); System.out.println(f); System.out.println(d); } }