This commit is contained in:
Oleksii Aleshchenko 2023-04-27 15:56:43 +03:00
parent 1690d0f9e4
commit 484bef389b
1 changed files with 37 additions and 0 deletions

View File

@ -1,10 +1,47 @@
public class Lab3 { public class Lab3 {
private static final int REPETITION_NUMBER = 10;
public static void main(String[] args) { public static void main(String[] args) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < REPETITION_NUMBER; i++) {
// result += Integer.toString(i);
// result += String.valueOf(i);
result.append(i);
}
/*float f = 1.1f;
double d = 2.2;
// f = (float) (f + d);
f += d;*/
String s = "ASD"; String s = "ASD";
StringBuilder stringBuilder = new StringBuilder("ASD"); StringBuilder stringBuilder = new StringBuilder("ASD");
StringBuffer stringBuffer = new StringBuffer("ASD");
stringBuilder.append("A"); stringBuilder.append("A");
System.out.println(s.length());
System.out.println(stringBuilder.length());
System.out.println(stringBuffer.length());
System.out.println(s.endsWith("D"));
// System.out.println(stringBuilder.substring(stringBuilder.length() - 1).equals("A"));
System.out.println("A".equals(stringBuilder.substring(stringBuilder.length() - 1)));
System.out.println("A".equals(stringBuffer.substring(stringBuffer.length() - 1)));
String sNull = null;
System.out.println("A".equals(sNull));
System.out.println(sNull.equals("A"));
System.out.println(s.substring(2));
System.out.println(s.contains("AS"));
System.out.println(s.indexOf('a'));
// System.out.println(s.charAt(-1));
System.out.println("s.equalsIgnoreCase(\"AsD\") = " + s.equalsIgnoreCase("AsD"));
String s2 = s; String s2 = s;
System.out.println("s2 = " + s2); System.out.println("s2 = " + s2);