• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Initialization of variables and arrays

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking for clarification. I am preparing for my certification exam and am getting conflicting info as to when variables and arrays are automatically initialized. As I understand it, all member variables (static or instance) are automatically initialized. False for booleans, 0 for all other primitives, and null for object references. Local variables are not initialized. Do I understand the rules of initialization correctly and do they also apply to arrays? Primitive array elements initialized to false or 0 and array elements of object references initialized to null?
------------------
Vince Clark
clarkvince@hotmail.com
 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vince,
You are right. All the Class members variables are initialised to
their respective defaul values . Arrays are set to thier default
values even in the methods.
Hope you are clear now.
Ravindra Mohan.
 
Blood pressure normal? What do I change to get "magnificent"? Maybe this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic