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

  • Home
  • SEARCH
  • 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 8926099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:52:58+00:00 2026-06-15T07:52:58+00:00

First of all, here’s the code: public class Test{ public static void main(String args[]){

  • 0

First of all, here’s the code:

public class Test{

   public static void main(String args[]){

    short[][] b = new short[4][4];
    short[][] big = new short[2][2];
    short b3 = 8;
    short b2 [][][][] = new short [2][3][2][2];

   // insert code here that will allow the code to compile

     }

}

This is a problem from a textbook, here are the two answers that are wrong:

b2[0][1][1] = b;

The explanation here is that it tries to assign a 2-dimensional array where a 1-dimensional array is expected. Can someone explain this? I do not see where a 1-dimension array is in the code at all.

b2[0][2][1] = b[1][0];

The explanation for this wrong answer is that it tries to assign a primitive short where a short array is expected. I’m baffled by this one because I don’t see a primitive short in this answer?

  • 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-15T07:52:59+00:00Added an answer on June 15, 2026 at 7:52 am

    in java a multi-dimentional array is actually an array of arrays.

    You can think of it as though every time you index the array(that means you put [i] after it) you lose a dimention.

    b
    

    gives a 2-dimentional array,

    b[i] 
    

    gives you a 1-dimentional array, and

    b[i][j]
    

    gives you a short (which is a primitive)

     b2[0][1][1]
    

    should also give you a 1 dimentional array, but you’re trying to put a 2-dimentional array there, which is the problem.

    now for the second wrong answer, b[i][j] gives you a primitive., and that’s what you’re trying to put where the 1-dimentional array should be.

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

Sidebar

Related Questions

First of all here are some code snippets: public void startThread() { this.animationThread =
First of All here's the Codes: Product Information: public class ProductInformation { public String
first at all, here is my code: string pdfTemplate = Application.StartupPath + \\Templates\\Template Medico.pdf;
first of all here is my code: @protocol SearchTableViewControllerDelegate @required - (void)didSelectFileCardsContent:(FileCardsContent*)content; @end @interface
First of all here is my code so that you can test it to
First of all i'm new in here and new with csharp. just exhausted while
First of all, here's my code: var users = {}; //User Connect io.sockets.on('connection', function
First of all, here is my code snippet: var str = '<!--:de-->some german text<!--:--><!--:en-->some
First of all, I am new here and just learning sql, so bear with
First of all, I'm new to programming and python, I've looked here but can't

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.