Парадигмы программирования
Много вопросов
String[][] strings = new String[10][];
String[][] strings = new String[][10];
int a[][] = new int[][]{{1, 2}, {3}, {}}
int a[] = new int[5]{1};
Object[] a = new Integer[1]; a[0] = "1"; System.out.println(a[0]);
System.out.println(a[-1]);
a[a.length * 4] = 10; System.out.println(a[a.length * 4]);
byte[] a = new byte[Integer.MAX_VALUE / 2 + 2]; a[a.length * 4] = 10; System.out.println(a[a.length * 4]);
class A { void hello1() { System.out.print(" 1A"); } static void hello2() { System.out.print(" 2A"); } } class B extends A { void hello1() { System.out.print(" 1B"); } static void hello2() { System.out.print(" 2B"); } } A a = new A(); a.hello1(); a.hello2(); B b = new B(); b.hello1(); b.hello2(); A c = new B(); c.hello1(); c.hello2();
interface Value { long getValue(); void setValue(long value); int intValue(); long value = 42; }
class SingleValue implements Value extends Long { protected long getValue() { return this.value; } public void setValue(int v) { value = v; } public static int intValue() { return (int) value; } }
public class AbstractStack { int size; int size(AbstractStack this) { return this.size; } ...
Outer.this.hello();
import example.name.*;
import example.name;
import example.Name.*;
import java.util.*; import java.util.List;
import java.awt.*;
import static example.Name.HELLO_WORLD;
import static example.Name.helloWorld;
int x = 0x10; x += 0x1234_5678_9abcL; System.out.format("%x", x);
void foo() { { int x = 10; System.out.println(x); } { String x = "hello"; System.out.println(x); } }
Integer.MIN_VALUE + Integer.MAX_VALUE
Double.MIN_VALUE + Double.MAX_VALUE
double p0 = 0.0; double n0 = -0.0; System.out.println(p0 == n0); // true System.out.println(1 / p0); // Infinity System.out.println(1 / n0); // -Infinity
double nan = 0.0 / 0; System.out.println(nan == nan); // false
Integer i1 = 100, i2 = 100; Integer i3 = 1000, i4 = 1000; System.out.println((i1 == i2) + " " + (i3 == i4));
x = x++ - ++x; System.out.println(x);
s = null; s += s; System.out.println(s);
class Example { }
try { // ... } catch (HelloException e) { // ... }
try { // ... } catch (HelloException e) { // ... } catch (ByeException e) { // ... }
try { throw new IOException("Hello"); } catch (Exception e) { System.out.println(1); } catch (IOException e) { System.out.println(2); }
int hello() { try { return 1; } finally { return 2; } }
try { // ... } catch (HelloException|ByeException e) { // ... }
try { // ... } catch (HelloException|ByeException e) { // ... }
try ( Hello h = new Hello(); Bye b = new Bye(); ) { // ... }
try ( Hello h = new Hello(); Bye b = new Bye(); ) { // ... }
try ( Hello h = new Hello(); Bye b = new Bye(); ) { // ... }
try ( Hello h = new Hello(); Bye b = new Bye(); ) { // ... }
OutputStream out = new FileOutputStream("hello"); out.write(0x12345678);