Write an operator style method called iota which takes one positive integer as its sole parameter and returns the array of integers containing 1,
2,
3, ... ,
n
-
where n is the parameter.
Example: an input of iota (5) would output:
1 2 3 4 5
static private int [] iota (int n)
{
int a [] = new int [n];
for (int x
=
0;
x
< =
n
-
1;
x + +)
{
a [x] = x
+
1;
}
return a;
}
Write an operator style method which makes a copy of an array of character strings.
static private String [] copy (String [] s)
{
for (int i
=
0;
i
<
s.length;
i + +)
{
c [i]
=
s [i];
}
return c;
}
|