• Post Reply Bookmark Topic Watch Topic
  • New Topic

state variables  RSS feed

 
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone please explain what are state variables in java
 
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch Gajendra.

Could you be more specific as to what is it that you do not understand? Do you know what is an object?
 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
i know little... that Object is a super class of all classes.
and while reading about add() method in collections,it said that add(Object o) "here we can pass any object reference in the add method,Object class declares no state variables,only methods are declared".so i did not understand this statement
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is correct. The class java.lang.Object indeed does not possess any state / field variables. State variables are nothing but variables that are declared outside a method and inside a class in java. For example:



These are called state or instance variables as they define the state of an Object of that class.
 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i got it now thank you
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!