Compare commits
3 Commits
455c991edb
...
9b871b6a42
Author | SHA1 | Date |
---|---|---|
Oleksii Aleshchenko | 9b871b6a42 | |
Oleksii Aleshchenko | e41e64369b | |
Oleksii Aleshchenko | 484bef389b |
|
@ -1,10 +1,47 @@
|
|||
public class Lab3 {
|
||||
private static final int REPETITION_NUMBER = 10;
|
||||
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";
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder("ASD");
|
||||
StringBuffer stringBuffer = new StringBuffer("ASD");
|
||||
|
||||
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;
|
||||
System.out.println("s2 = " + s2);
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package test.one;
|
||||
|
||||
public class A implements MyMethodInterface {
|
||||
public void myMethod() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package test.one;
|
||||
|
||||
public class B implements MyMethodInterface {
|
||||
public void myMethod() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package test.one;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Object[] objects = {
|
||||
new A(),
|
||||
new B(),
|
||||
};
|
||||
for (Object object : objects) {
|
||||
((MyMethodInterface)object).myMethod();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package test.one;
|
||||
|
||||
public interface MyMethodInterface {
|
||||
void myMethod();
|
||||
}
|
Loading…
Reference in New Issue