• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Query Regrading 'this'

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When i tried to compile following program , it gives error " Can't Assign value to final variable this " Could you please explain it ?

public class ThisUsage {
int planets;
static int suns;
public void gaze() {
int i;
this = new ThisUsage(); // Compilation error comes here


}
}
Many Thanks and Regards,
Somesh Rathi
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
'this' in program represents current object ....
it is not right when your righting this=new object();
you can use any varible of that object by this.varible but you can't use 'this' directly ok
if you need some more clarfication pls go to sun site java.sun.com tutorials....[URL=http://www.java.sun.com]

Regrads
Madhav
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
15.8.3 this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic