public void go()
{
ripper(10,11,15,-1);
}
public void ripper(short... args)
{
System.out.print(args.length);
}
Ответ
Не скомпилируется
В метод ripper мы передаем int, ожидается short
В метод ripper мы передаем int, ожидается short
public void go()
{
ripper(10,11,15,-1);
}
public void ripper(short... args)
{
System.out.print(args.length);
}
Object hobject = new Short[4];
class Test {
public static void main(String[] args) {
Devil dev = new Boast(1);
}
}
class Boast extends Devil
{
public Boast(){System.out.print("boast ");}
public Boast(int i)
{}
}
class Devil
{
public Devil(){System.out.print("devil ");}
public Devil(int i)
{}
}
class T1 extends T {}
class T2 extends T {}
class T {
public static int i;
}
public class Test {
public static void main(String[] args) {
T1.i = 5;
T2.i = 3;
System.out.format("%d = %d", T1.i, T2.i);
}
}
Integer i1 = Integer.valueOf(11);
Integer i2 = Integer.valueOf(11);
System.out.println(i1 == i2);
Integer i3 = Integer.valueOf(10000);
Integer i4 = Integer.valueOf(10000);
System.out.println(i3 == i4);
public class Parent {
Parent() {
test();
}
public static void main(String[] args) {
new Child();
}
protected void test() {
System.out.println("Hello from Parent");
}
}
class Child extends Parent {
private final String someString;
Child() {
someString = "some Text";
}
protected void test() {
System.out.println("Hello from Child");
System.out.println(someString);
}
}
class Test {
public static void main(String[] args) {
String s = "old";
print(s, s = "new");
}
static void print(String s1, String s2) {
System.out.println(s1 + " " + s2);
}
}
private static int foo() {
int a = 1;
int b = 2;
try {
return a + b;
} finally {
a = 10;
b = 20;
return a + b;
}
}
int x = 4;
System.out.println("value is " + ((x > 4) ? 99.99 : 9));
public class Animal {
private final String type;
Animal(String type) {
this.type = type;
}
public boolean equals(Animal animal) {
return type.equals(animal.type);
}
public int hashCode() {
return type.hashCode();
}
public static void main(String[] args) {
Set set = new HashSet();
set.add(new Animal("Dog"));
set.add(new Animal("Cat"));
set.add(new Animal("Cat"));
System.out.println(set.size());
}
}
System.out.println(1 + 2 + 3 + "" + 4 + 5 + 6);