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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:38:50+00:00 2026-06-04T04:38:50+00:00

If I initialize an array in a Java method like: final double[][] myArray =

  • 0

If I initialize an array in a Java method like:

final double[][] myArray = new double[r][c];

Will I be allowed to do this later in the method?

myArray[0] = new double[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-04T04:38:51+00:00Added an answer on June 4, 2026 at 4:38 am

    I’ll provide you an example of this:

    public class Main {
        public static void main(String[] args) {
            final int[] finalArray = new int[5];
            finalArray[0] = 10;
            System.out.println(finalArray[0]);
            finalArray[0] = 9001;
            System.out.println(finalArray[0]);
            finalArray = new int[5] //compile error!!!
        }
    }
    

    This is because the final modifier will say that the reference to the array (the pointer) can’t change, but the elements of the array (that could have another pointer) can change with no problem.

    EDIT:

    Another example with 2d array:

    public class Main {
        public static void main(String[] args) {
            final int[][] array2d = new int[5][];
            for(int i = 0; i < array2d.length;i++) {
                array2d[i] = new int[6];
            }
            //the size of the rows can change with no problem.
            array2d[0] = new int[8];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw someone initialize and array like this in java int[] s; s =
In PHP you can do the following: method(array(a, b)); Can you in Java initialize
To create and initialize an array with another array I currently do this: void
In Java is there anyway to have one constructor that will accept an array
The Java Docs for the method String[] java.io.File.list(FilenameFilter filter) includes this in the returns
I am new to Java, I want to store an array of pair of
In Java, it is completely legal to initialize a String array in the following
I'm trying to understand the array setup in java. Why must you initialize space
I wish to initialize an array of java methods in the child class, as
How do I declare and initialize an array in Java?

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.