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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:42:59+00:00 2026-05-29T04:42:59+00:00

Is there a way to initialise an array of integers (or possibly any array)

  • 0

Is there a way to initialise an array of integers (or possibly any array) to a constant value other than zero (or null) which are the defaults, without a for loop?

Ideally I am looking for a function like “ones” in matlab, which is not only neater but also more efficient.

  • 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-29T04:43:01+00:00Added an answer on May 29, 2026 at 4:43 am

    Arrays.fill() is the method you’re after. (Although internally it still uses a for loop, so unlike System.arrayCopy(), it isn’t any faster.)

    P.s.: Arrays, and its collection-based counterpart Collections are two extremely useful classes in general.

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

Sidebar

Related Questions

Is there a way to initialize all elements of an array to a constant
I have a plugin which is applied on few element. Is there any way
Is there more elegant way(LINQ or other) to initialize array like this? int[] result
Is there are an easy way to initialize byte array from portion of existing
I'm using the vector container to store an array of doubles. Is there any
I'm trying to initialise a structure which ends with an array[0] (here, char iedata[0]
Is there a way to declare first and then initialize an array in C?
In Java is there any way of writing a loop so that you can
Is there way to initialize a numpy array of a shape and add to
Possible Duplicate: Is there memset() that accepts integers larger than char? As it can

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.