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.


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
    Junior Member
    Join Date
    Aug 2013
    Thanked 1 Time in 1 Post

    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
    SW Missouri
    Thanked 2,158 Times in 2,131 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
    Thanked 322 Times in 300 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).

    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, 10: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