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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:14:15+00:00 2026-05-17T15:14:15+00:00

In practice can I assume that all int arrays in Java will start out

  • 0

In practice can I assume that all int arrays in Java will start out filled with zeros? for all machines in which the JVM runs?

Is this true for all types? char? boolean? enums?

Where is this officially documented?

The textbooks I have say that int arrays are set to zero but they also recommend that one should write a for-loop to set all values to zero just “to be clearer”.

  • 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-17T15:14:16+00:00Added an answer on May 17, 2026 at 3:14 pm

    Java Language Specification is the right place to look for such information:

    Array components are unnamed variables that are created and initialized to default values (§4.12.5) whenever a new object that is an array is created

    Default values themselves are given in section 4.12.5.

    • For type byte, the default value is zero, that is, the value of (byte)0.
    • For type short, the default value is zero, that is, the value of (short)0.
    • For type int, the default value is zero, that is, 0.
    • For type long, the default value is zero, that is, 0L.
    • For type float, the default value is positive zero, that is, 0.0f.
    • For type double, the default value is positive zero, that is, 0.0d.
    • For type char, the default value is the null character, that is, ‘\u0000’.
    • For type boolean, the default value is false.
    • For all reference types, the default value is null.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During practice of customizing VirtualPathProvider, I found that it the custom VirtualPathProvider can be
Can the performance of this sequential search algorithm (taken from The Practice of Programming
Since I can't use Microsoft as an example for best practice since their exception
Assuming you can't use LINQ for whatever reason, is it a better practice to
I'm not sure what this practice is actually called, so perhaps someone can edit
Wikipedia states: In practice, explicit right outer joins are rarely used, since they can
This is clearly not appears like it wouldn't be a best practice. Can someone
Where can I find some good pointers on best practices for running ASP.NET MVC
Can anyone recommend some best-practices on how to tackle the problem of starting to
apparently it works Can you name reasons beyond good practices not to give these

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.