Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

clarify this keyword used in my java program  RSS feed

 
venkateswarlu keesara
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class Test {
public static void test() {
this.print();
}
public static void print() {
System.out.println(�Test�);
}
public static void main ( String args[]) {
test();
}
}
ans:compilation error:
non static "this" variable can not be refernced from static method
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This forum is meant for issues with the JavaRanch forum itself. I will have someone move it to the correct forum: Java Beg.

Eric
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Java in General (beginner) forum...
[ October 08, 2004: Message edited by: Dirk Schreckmann ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!