• 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

Basic question

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I came with a very basic question about swing component. Could
anybody clear it out?
Sometimes i find class instance in both way.

label = new JLabel("Click.", JLabel.CENTER); // 1st statem
Jlabel label = new JLabel("Click.", JLabel.CENTER); // 2nd statem
In the 2nd statement, i am instantiating and intialising
Jlabel constructor as label and a copy of reference to
the Jlabel Object, isn't it?.
My question is that why sometimes we use the 1st statement to
give a same effect instead of second. In the 1st statement
there is no Jlabel Object?
Do appreciate if you clarify that.
Thanks,
Golam Newaz

 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You must have created the container for the variable earlier in the program.
Campfire Stories has an amusing story which reviews how variables are created and initialized: http://www.javaranch.com/campfire/StoryCups.jsp
 
Golam Newaz
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for providing an amazing page my dear pal, Cindy.
Now almost clear about OO language. Javaranch.com is our
object. You were controlling with one remote control and
when i asked help you gave me a copy of your remote control (
a copy of reference ) but javaranch.com object is same,
when your location (name of reference ) and my location is different,isn't it?
Thanks a lot,
Golam Newaz.
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
great goalm
deeksha
 
reply
    Bookmark Topic Watch Topic
  • New Topic