Difference between revisions of "PrintArray Method"
From CompSciWiki
Line 1: | Line 1: | ||
{{1010PrAD|ProblemName=printArray Method | {{1010PrAD|ProblemName=printArray Method | ||
− | |Problem= | + | |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. | ||
Revision as of 12:46, 30 March 2010
Back to the Program-A-Day homepage
ProblemPretend 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
An image or By Students section | |
---|---|---|
SolutionThe solution... | ||
CodeSolutionCode goes here. Please DO NOT put your code in <pre> tags! |