Homework 3
This commit is contained in:
parent
bf60a078d7
commit
0afc86ceeb
129 changed files with 3163 additions and 4316 deletions
|
@ -0,0 +1,16 @@
|
|||
// Test that arrays are not covariant
|
||||
|
||||
class Main {
|
||||
void main() {
|
||||
boolean y;
|
||||
A[] Array1;
|
||||
B[] Array2;
|
||||
Array2 = new B[10];
|
||||
|
||||
Array1 = Array2;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {}
|
||||
|
||||
class A {}
|
|
@ -0,0 +1,11 @@
|
|||
// The left-hand side of an assignment cannot be a method call
|
||||
// Valid options are variable accesses, fields or an indexed array
|
||||
|
||||
class Main {
|
||||
void main() {
|
||||
action() = read();
|
||||
}
|
||||
int action() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
// The left-hand side of an assignment cannot be a reference to this
|
||||
// Valid options are variable accesses, fields or an indexed array
|
||||
|
||||
class Main {
|
||||
void main () {
|
||||
int b;
|
||||
int[] c;
|
||||
c = new int[5];
|
||||
this.a = 10;
|
||||
b = 10;
|
||||
c[4] = 10;
|
||||
this = null;
|
||||
}
|
||||
int a;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue