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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:05:20+00:00 2026-06-11T03:05:20+00:00

For example, one might initialize a character array as: char[] myArray = new char[3];

  • 0

For example, one might initialize a character array as:

char[] myArray = new char[3];
myArray = {'a', 'b', 'c'};

Or one might initialize the character array as:

char[] myArray = {'a','b', 'c'};

What is the benefit of using the “new” methodology ?

Incidentally, in the first example, why am I also allowed to assign the { … } set without passing it to a constructor method (in parenthesis)?

char[] myArray = new char[] {'a', 'b', '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-11T03:05:21+00:00Added an answer on June 11, 2026 at 3:05 am

    {and} is a Short cut syntax and here the length of the array is determined by the number of values provided between { and }.

    From Arrays Oracle docs

    One way to create an array is with the new operator. The next statement in the ArrayDemo program allocates an array with enough memory for ten integer elements and assigns the array to the anArray variable.

    // create an array of integers
    anArray = new int[10];
    

    Alternatively, you can use the shortcut syntax to create and initialize an array:

    int[] anArray = { 
    100, 200, 300,
    400, 500, 600, 
    700, 800, 900, 1000
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is an example of one of our data calls in our DAL using
I have a table, has many rows. for example one of from rows(all rows
I have a table, has many rows. for example one of from rows(all rows
I create one example in Android 3.0 and I use the fragment in it.
I found one example in which buttons are added to panels (instances of JPanel
i am trying one example from Here for ontouch image zoom and touch on
The Mongoid documentation only gives one example of doing a wildcard search: Person.where(first_name: /^d/i)
I'm getting the following from a third party library (one example): @%SystemRoot%\SomePath\SomeFile.Dll,-203 I know
I am trying to display(block,none) select boxes(in this example only one select box) through
I start to use Java annotations heavily. One example is taking method with annotations

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.