PrintArray Method

From CompSciWiki
Revision as of 12:46, 30 March 2010 by DavidS (Talk | contribs)

Jump to: navigation, search

Back to the Program-A-Day homepage

Problem

Pretend you're a computer science professor. You have a program which stores the names of all the students in each of your classes in separate arrays, based on the class they are in. How would you go about printing the contents of each of these arrays?

On one hand, you could copy and paste a loop into your main method to print each of the arrays, but that would use a lot of redundant code. Instead, it would be good to write a method to print an array, and call it every time you want to print one of your class lists.

 

SideSectionTitle

float
Taken from http://www.flickr.com/photos/daniello/565304023/

An image or By Students section

Solution

The solution...

Code

SolutionCode goes here. Please DO NOT put your code in <pre> tags!

Back to the Program-A-Day homepage