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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:43:07+00:00 2026-05-31T23:43:07+00:00

5 import java.util.*; 6 7 class Matrix { 8 // declare the member field

  • 0
  5 import java.util.*;
  6 
  7 class Matrix {
  8     // declare the member field
  9     private int[][] matrix;
 10 
 12     public Matrix(int a, int b, int c, int d) {
 13         matrix = new int[2][2];
 14         matrix[0][0] = a;
 15         matrix[0][1] = b;
 16         matrix[1][0] = c;
 17         matrix[1][1] = d;
 18     }
 19     // identity matrix
 20     public Matrix(char i) {
 21         matrix = new int[2][2];
 22         matrix[0][0] = 1;
 23         matrix[0][1] = 0;
 24         matrix[1][0] = 1;
 25         matrix[1][1] = 0;
 26     }
 27 
 29     public int[][] toPow(int n, int[][] matrix) {
 30         if (n == 1)
 31             return matrix;
 32         else {
 33             int[][] temp = matrix;
 34             for (int i = 0; i < 2; i++) {
 35                 for (int j = 0; j < 2; j++) {
 36                     temp[i][j] += matrix[i][j] * this.matrix[j][i];
 37                 }
 38             }
 39             return toPow(n - 1, temp);
 40         }
 41     }
 42     public int[][] toPow(int n) {
 43         return toPow(n, this.matrix);
 44     }
 45 }
 46 
 47 class Maths {
 48 
 49     public static void main(String[] args) {
 55         Matrix m = new Matrix(1,2,3,4);
 56         System.out.println(Arrays.toString(m.toPow(2)));
 57         System.out.println(Arrays.toString(new int[][] {{1,2},{3,4}}));
 58     }
 59 }

Arrays.toString(Array) should be printing out the contents of the array when called. But when I tried to print the array in the last 2 lines of the code, I get the addresses instead of the content. Can anyone please help me understand why that is?

  • 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-31T23:43:09+00:00Added an answer on May 31, 2026 at 11:43 pm

    You’re seeing the results of calling toString() on each element of your top array. But each element is itself an array. Use Arrays.deepToString() instead:

    System.out.println(Arrays.deepToString(m.toPow(2)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

import java.util.Random; import java.util.Scanner; public class Lottery { private int[] lotteryNumbers = new int[5];
Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private
import java.util.Random class Kostka { val rand = new Random(System.currentTimeMillis()) val value: List[Int] =
import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; public class Main implements Runnable { private final CountDownLatch cdl1
Hi have one class like this import java.util.ArrayList; public class MobilePhone { private String
import java.util.*; class Averager { public static double unlimited() { int count = 0;
import java.util.AbstractList; public class ItemSet extends AbstractList { private Item[] arr; private ItemClass itemClass;
import java.util.*; class AddressBook { private static final int DEFAULT_SIZE = 25; private Person[]
import java.util.*; import org.directwebremoting.util.Logger; public class People { public People() { people = new
import java.io.*; import java.util.Scanner; import java.util.StringTokenizer; public class Filereader { public static void main(String[]

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.