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 3 of 3

Thread: What is this declaration considered?

  1. #1
    Member
    Join Date
    Aug 2013
    Posts
    95
    Thanks
    3
    Thanked 14 Times in 14 Posts

    Default What is this declaration considered?

    When you say

    int array[];

    I know that this is declaring an array without a size. Does that mean that this is "Sort" of like a pointer. A slot in memory waiting for an address to fill its value?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: What is this declaration considered?

    Yes. An array is a type of object. Defining an object variable without assigning a value:
    Object anObject;
    The default value would be null;

    The normal java way to define an array is with the [] after the type not the name:
    int[] anArray;
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: What is this declaration considered?

    It's more like reserving the variable name than anything else. No significant memory is allocated until the array is initialized (as far as I know).
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. error in declaration of try statement.
    By edward005 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 1st, 2013, 02:51 AM
  2. how is the correct declaration of character? I need it now. Somebody help
    By daryll_1210 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 21st, 2013, 09:01 PM
  3. Would the following be considered bad practice in Java?
    By Newbie_71 in forum Java Theory & Questions
    Replies: 2
    Last Post: September 19th, 2011, 10:49 PM
  4. Variable declaration placement
    By 2nickpick in forum Java Theory & Questions
    Replies: 2
    Last Post: January 22nd, 2011, 11:34 AM
  5. [SOLVED] Method declaration in Java
    By mohsendeveloper in forum Object Oriented Programming
    Replies: 4
    Last Post: June 11th, 2009, 03:18 AM