Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

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.

added 12 characters in body
Source Link
Rob Audenaerde
  • 3.5k
  • 15
  • 24

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.

Source Link
Rob Audenaerde
  • 3.5k
  • 15
  • 24

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 );
 }
lang-java

AltStyle によって変換されたページ (->オリジナル) /