Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: initialize an array

  1. #1
    Junior Member
    Join Date
    Jul 2019
    Posts
    10
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default initialize an array

    Why would one initialize an array like:
    int arr[] = new int[] {1,2,3,4};

    Instead of:
    int arr[] = {1,2,3,4};

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,475
    Thanks
    53
    Thanked 2,405 Times in 2,358 Posts

    Default Re: initialize an array

    personal preference or shop requirement.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    jenniferruurs (October 6th, 2019)

  4. #3
    Junior Member
    Join Date
    Jul 2019
    Posts
    10
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: initialize an array

    What is a shop requirement?

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,475
    Thanks
    53
    Thanked 2,405 Times in 2,358 Posts

    Default Re: initialize an array

    The company you work for can have coding standards.
    If you don't understand my answer, don't ignore it, ask a question.

  6. The Following User Says Thank You to Norm For This Useful Post:

    jenniferruurs (October 6th, 2019)

Similar Threads

  1. JVM failed to initialize
    By Aceix in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 30th, 2014, 12:10 PM
  2. Var Might have been initialize
    By Evilreaper in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 15th, 2012, 10:27 AM
  3. Initialize Map size
    By mano123 in forum Collections and Generics
    Replies: 2
    Last Post: May 29th, 2012, 12:05 AM
  4. Re-Initialize array without loosing contents..
    By Mr.777 in forum Java Theory & Questions
    Replies: 7
    Last Post: June 17th, 2011, 05:47 AM
  5. I'm not sure how to initialize GraphicsDevice and Window
    By DotChris in forum AWT / Java Swing
    Replies: 3
    Last Post: July 15th, 2009, 09:00 AM