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 8739435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:56:14+00:00 2026-06-13T10:56:14+00:00

I have a 2d array made up of columns and rows and when computed

  • 0

I have a 2d array made up of columns and rows and when computed it builds a matrix or the values in the matrix but the problem is that my text area is displaying only my final result in my 2d array and not all the others but in my console in netbeans it does display all the values How may I change my code to enable this.Below are the pieces that I think is where the problem is coming. Thank you

This is in my actionperform button to display the

     for (int i =0; i < rows; i++) {
       for (int j = 0; j < cols; j++) {
         matrix_tf.setText(String.valueOf(matrix[i][j]));

and this is the code to compute my matrix

    private void build_matrix() {
    String seq1 = sequence1_tf.getText();
    String seq2 = sequence2_tf.getText();



    int r, c, ins, sub, del;

    rows = seq1.length();
    cols = seq2.length();

    matrix = new int [rows][cols];

    // initiate first row
    for (c = 0; c < cols; c++)
        matrix[0][c] = 0;

    // keep track of the maximum score
    max_row = max_col = max_score = 0;

    // calculates the similarity matrix (row-wise)
    for (r = 1; r < rows; r++)
    {
        // initiate first column
        matrix[r][0] = 0;

        for (c = 1; c < cols; c++)
        {
                        sub = matrix[r-1][c-1] + scoreSubstitution(seq1.charAt(r),seq2.charAt(c));
                        ins = matrix[r][c-1] + scoreInsertion(seq2.charAt(c));
                        del = matrix[r-1][c] + scoreDeletion(seq1.charAt(r));

            // choose the greatest
            matrix[r][c] = max (ins, sub, del, 0);

            if (matrix[r][c] > max_score)
            {
                // keep track of the maximum score
                max_score = matrix[r][c];
                max_row = r; max_col = c;
            }
        }
    }
}
  • 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-06-13T10:56:15+00:00Added an answer on June 13, 2026 at 10:56 am

    In this loop :

     for (int i =0; i < rows; i++) {
       for (int j = 0; j < cols; j++) {
         matrix_tf.setText(String.valueOf(matrix[i][j]));
    

    you set the text of your field on each iteration (setting the text overwrites the prvioues one). Try concatenating your texts :

     for (int i =0; i < rows; i++) {
       for (int j = 0; j < cols; j++) {
         matrix_tf.setText(matrix_tf.getText() + " " + String.valueOf(matrix[i][j]));
    

    If you are using a text area (and not a text field) use append as @Sujay suggested

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

Sidebar

Related Questions

I have an array that I want on multiple pages, so I made it
I have made an app that gets an array of addresses from a web
PHP: I have made up a function that returns an array. I would like
I have a map made up of rows and columns of hexagons This isn't
I have an array made of unlimited number of objects. These objects have the
I have a 2d array grid made as int GRID[10][20]; What I want to
So i have 2 classes, users and health readings. i made a array of
I have made a String[] array by using String.split(.) . I am now trying
I have made an normal form that you can enter a user´s fullname in
I have a 2D-array that I want to sort based on the second column.

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.