This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

where is the array going to created  RSS feed

 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it can't be class varible.because i didn't make it as a static?
 
Embla Tingeling
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 55717
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the posh name for such a member variable is an instance field.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!