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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:32:05+00:00 2026-06-16T05:32:05+00:00

I have some questions regarding arrays in java: How many objects are created in

  • 0

I have some questions regarding arrays in java:

How many objects are created in the following expressions?

(a) new int[0] : There is one object created, an array of size 0.???

(b) new int[2][2] : There is one object created, an array with 2 rows and columns.???

(c) new int[2][] : There is no object created???

I was wondering if my solutions next to the expressions are correct. If not, hopefuly you can help and give me some explanation about them. I don’t really get what im supposed to do.

Thanks in advance!

  • 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-16T05:32:08+00:00Added an answer on June 16, 2026 at 5:32 am

    new int[0]

    Yes this is an empty array, one object is created.

        int[] emptyArray = new int[0];
        System.out.println(emptyArray.length); // Outputs 0
    

    new int[2][2]

    Yes this creates and array with 2 rows and columns, 3 objects are created.

        int[][] bar = new int[2][2];
        System.out.println(bar.getClass()); // Outputs class [[I
        int[] bar1 = bar[0];
        System.out.println(bar1.getClass());  // Outputs class [I
        int[] bar2 = bar[1];
        System.out.println(bar2.getClass());  // Outputs class [I
    

    new int[2][]

    Java supports jagged arrays. This means when you create int[2][] this means you have an array of various sized int[]. Only 1 object is created here.

        int[][] foo = new int[2][];
        System.out.println(foo[0]);  // Outputs null
        System.out.println(foo[1]);  // Outputs null
        foo[0] = new int[10];
        foo[1] = new int[5];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some questions regarding the following css that I found: html, body {
There have been some similar questions asked regarding Grid views, but none have been
I've read some documentation on how Adaboost works but have some questions regarding it.
I have couple questions regarding some C++ rules. Why am I able to call
I have some question over here regarding the java garbage collector. First let me
I have a question regarding the some data which is being transfered from one
Regarding Java NIO2. Suppose we have the following to listen to client requests... asyncServerSocketChannel.accept(null,
I have a question regarding ResultSet objects in Java and recursion. I was working
I have some question about arrays, I'm reading some book about Java, and now
I have several questions regarding CI application design. Q. When creating a new form

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.