aspose file tools*
The moose likes Beginning Java and the fly likes where is the array going to created Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "where is the array going to created" Watch "where is the array going to created" New topic
Author

where is the array going to created

anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237


if this is the my class where is the legs array created.because it is in the class not inside a method?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14107
    
  16

It's a member variable of the class. The array will be created when you create a new dog object.

Have a look at Sun's Java tutorials, especially Lesson: Classes and Objects.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
it can't be class varible.because i didn't make it as a static?
Embla Tingeling
Ranch Hand

Joined: Oct 22, 2009
Posts: 237
anarkali perera wrote:it can't be class varible.because i didn't make it as a static?


That's right. If you make it static then there will be one array only, available to all objects of the class. If you make it non-static like now, then every object will have an array of its own.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38357
    
  23
I think the posh name for such a member variable is an instance field.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: where is the array going to created