I have three files, as shown below. When I run code inspection, it suggests
that joe.klyde can be static: "Does not use context instance fields or calls
context instance methods and therefore can have static modifier. " However,
joe.klyde can not be made static in this case. If I make it static, the
compiler reports: "Error:  line (11) non-static variable this cannot be
referenced from a static context".

-----test.java-----
class test
{
 public static void main( String[] args )
 {
  System.out.println( new joe() );
 }
}
------(EOF)------

-----fred.java-----
class fred
{
 private int  fTotal = 0;
 fred() { fTotal++; }

 class Attributes
 {
  private final String fString = "hello" + fTotal;

  public String toString()
  {
   return fString;
  }
 }
}
------(EOF)------

-----joe.java-----

class joe extends fred
{
 public String toString()
 {
  return "joe: " + new klyde();
 }

 private class klyde
 {
  private final Object fAttrs = new fred.Attributes();

  public String toString()
  {
   return fAttrs.toString();
  }
 }
}
------(EOF)------



_______________________________________________
Eap-bugs mailing list
[EMAIL PROTECTED]
http://lists.jetbrains.com/mailman/listinfo/eap-bugs

Reply via email to