Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Creating Arrays and sum its diagonal...

Write a method that sums all the numbers in the major diagonal in an n x n matrix of double values using the following header:

public static double sumMajorDiagonal(double [][] m)

Write a test program that first prompts the user to enter the dimension n of an n x n matrix, then asks them to enter the matrix row by row (with the elements separated by spaces). The program should then print out the sum of the major diagonal of the matrix.

This is the question to the exercise. Now I feel confuse..because should i create and array[n][n] and then ask the user for the inputs and some how using the for loop to connect all that information?

Little help would super great...

Thank you