• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is the different between Object and Context ?

 
Greenhorn
Posts: 17
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai...
Friends..

I don't understand
What is the different between object and context ?

can any one please help

Advanced thanks....
 
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An object is what's created anytime that you use the "new" keyword. You declare classes, using the "class" keyword and then you create objects from classes with the "new" keyword.

A context is a particular place in your code, such as the context of being within a certain method. There are contexts where you can refer to your object's instance variable.

Here is an example program that create an object of the class Dog. Notice that there are two main contexts here: 1) from within the main() method, you are in a static context. 2) in the other parts of this code, for example in the Constructor and in the toString() method, you are running in a context where the instance variables "name", "height" and "weight" are all available. In the context of the constructor notice that there are two things named "name" and two things named "height" and "weight". To keep the compiler straight in this context I've used the "this" keyword when I wanted to refer to the instance variable and just used the parameter name when I wanted to use the parameter.

 
Hemakanta Sethi
Greenhorn
Posts: 17
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kaydell Leavitt wrote:An object is what's created anytime that you use the "new" keyword. You declare classes, using the "class" keyword and then you create objects from classes with the "new" keyword.

A context is a particular place in your code, such as the context of being within a certain method. There are contexts where you can refer to your object's instance variable.

Here is an example program that create an object of the class Dog. Notice that there are two main contexts here: 1) from within the main() method, you are in a static context. 2) in the other parts of this code, for example in the Constructor and in the toString() method, you are running in a context where the instance variables "name", "height" and "weight" are all available. In the context of the constructor notice that there are two things named "name" and two things named "height" and "weight". To keep the compiler straight in this context I've used the "this" keyword when I wanted to refer to the instance variable and just used the parameter name when I wanted to use the parameter.


Thank you Mr. Kaydell Leavitt
I got the idea, in case of Servlet we use ServletContext, so in this case what is the meaning the object and context
 
reply
    Bookmark Topic Watch Topic
  • New Topic