oneToN

In this problem, you're practicing creating a list and adding specific elements to it that are generated using a loop. (Combining your knowledge of iteration and lists)

Complete the method below that returns an ArrayList containing the numbers from 1 to n where n >= 1.

oneToN(5)-> [ 1, 2, 3, 4, 5] (pseudocode)
oneToN(3)-> [ 1, 2, 3] (pseudocode)
oneToN(2)-> [ 1, 2] (pseudocode) 

 How can you write a loop to generate the values for the elements?

The following are methods of a list that can be used to manipulate the contained data.

Type your solution        
Skills Practiced:
3.C
3.D
4.A
4.B
Copyright © StudyCS 2024 All rights reserved.