For task 2, you could use Java8 Stream Stream api for selectRectangle
public static Rectangle[] selectRectangle(Region[] regions) {
return Arrays.stream( regions )
.filter( r -> r instanceof Rectangle )
.toArray( Rectangle[]::new );
}
Btw, just a matter of taste, but I prefer variables that are a list or array of objects, to be plural. This allows you so see quickly that you are dealing with multiple object by just looking at the variable name.
For task 2, you could use Java8 Stream api for selectRectangle
public static Rectangle[] selectRectangle(Region[] regions) {
return Arrays.stream( regions )
.filter( r -> r instanceof Rectangle )
.toArray( Rectangle[]::new );
}
Btw, just a matter of taste, but I prefer variables that are a list or array of objects, to be plural. This allows you so see quickly that you are dealing with multiple object by just looking at the variable name.
For task 2, you could use Java8 Stream api for selectRectangle
public static Rectangle[] selectRectangle(Region[] regions) {
return Arrays.stream( regions )
.filter( r -> r instanceof Rectangle )
.toArray( Rectangle[]::new );
}
Btw, just a matter of taste, but I prefer variables that are a list or array of objects, to be plural. This allows you so see quickly that you are dealing with multiple object by just looking at the variable name.
YouFor task 2, you could use Java8 Stream api for selectRectangle
public static Rectangle[] selectRectangle(Region[] regionregions) {
return Arrays.stream( regionregions )
.filter( r -> r instanceof Rectangle )
.toArray( Rectangle[]::new );
}
Btw, just a matter of taste, but I prefer variables that are a list or array of objects, to be plural. This allows you so see quickly that you are dealing with multiple object by just looking at the variable name.
You could use Java8 Stream api for selectRectangle
public static Rectangle[] selectRectangle(Region[] region) {
return Arrays.stream( region )
.filter( r -> r instanceof Rectangle )
.toArray( Rectangle[]::new );
}
For task 2, you could use Java8 Stream api for selectRectangle
public static Rectangle[] selectRectangle(Region[] regions) {
return Arrays.stream( regions )
.filter( r -> r instanceof Rectangle )
.toArray( Rectangle[]::new );
}
Btw, just a matter of taste, but I prefer variables that are a list or array of objects, to be plural. This allows you so see quickly that you are dealing with multiple object by just looking at the variable name.
You could use Java8 Stream api for selectRectangle
public static Rectangle[] selectRectangle(Region[] region) {
return Arrays.stream( region )
.filter( r -> r instanceof Rectangle )
.toArray( Rectangle[]::new );
}