Commit 9135d9c5 authored by yazan.halloul's avatar yazan.halloul

handle error create data commit

parent 88771451
......@@ -7,7 +7,7 @@ import parallelCounters.*;
public class Main {
public static void main(String[] args) {
int start = 0;
int finish = 10;
int finish = -1;
int[] data = RangeArrayBuilder.create(start, finish);
for (int d:data
) {
......
......@@ -2,10 +2,14 @@ package data;
public class RangeArrayBuilder {
public static int[] create(int start, int finish) {
if(start > finish) System.out.println("Error!!: Finish value should be grater than Start value");
else {
int[] data = new int[finish - start + 1];
for (int i = start; i <= finish; i++) {
data[i - start] = i;
}
return data;
}
return new int[0];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment