Return to Jeff's Main Page

CS1 at Oswego

Hypertexknowlogy

Frequently Asked Questions

 
My Intro to Object-Oriented Programming  
 
 
 
Class Notes

Wednesday November 8 , 2000
 
Class started out by writing some operator-style methods. 


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;

From here,  CG wrote some code ``hints'' for our next programming assignment.