Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7566813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:30:30+00:00 2026-05-30T14:30:30+00:00

I have a problem with an (I guess) simple Java program. I need to

  • 0

I have a problem with an (I guess) simple Java program. I need to create a two-dimensional array (that is called a “matrix”, right?) which should look like this:

1 2 3 4  5  6  7  8  9 10   (1st row)
3 4 5 6  7  8  9 10 11 12   (2nd row)
6 7 8 9 10 11 12 13 14 15   (3rd row)
...

As you can see, the 1st row is 1, 2, 3, …; the 2nd row is the 1st row with the 2nd row’s row index added to each element. And so on: Every row is the previous row + the current row’s row number (1-based).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:30:32+00:00Added an answer on May 30, 2026 at 2:30 pm

    First define the number of columns and rows, and instantiate the array:

    int columns = 10, rows = 3;
    int[][] myArray = new int[rows][columns];
    

    Then do a loop for every row, and inside that loop, loop for every column, let’s say you call the outer loop counter i and the inner loop counter j. Then you can assign a value in the array using this formula:

    myArray[i][j] = j + ( (i+1) * (i+2) ) / 2;
    

    This formula assumes 0 <= i < rows and 0 <= j < columns

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some code in java that will guess a number based on
I'm new in java, so i guess it's a simple problem. In my event
I have problem in some JavaScript that I am writing where the Switch statement
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with fancybox. I want to write a function that will run
I have a simple java gui calculator, with 3 number systems (there are some
I have a seemingly simple problem though i am unable to get my head
I have a simple problem but I just don't understand any of the examples
We have a large (>500,000 LOC) Java system that depends on 40-50 OSS packages.
When Connected: I have a simple HTML page with some image elements that reference

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.