Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Objects Encapsulation and Arrays Arrays

Set the first double in the array to 2.2

just not getting this... I understand I need to include the index number between the brackets, but keep trying the different brackets to make this work and just not understanding this

double[2.2] lapTimes[] = new double[4] lapTimes[2.2]; 

1 Answer

Steve Agusta
Steve Agusta
6,220 Points

It looks like you've got the concept of declaring the array, but the syntax for the declaration and initialization are not quite right. let's look at the array declaration first. How would you write that on its own, to declare an array of doubles with a length of 4?

double[] lapTimes = new double[4]; lapTimes[0] = 2.2;

Thanks Steve for the help!!