import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public class A
{
int a; char b;
public A(int x, char y )
{
a=x; b=y;
}
public void print()
{
System.out.println("Print function called");
}
public A()
{
}
}
public interface B
{
void unfriend();
}
public class C extends A implements B
{
char d;
public C(int x, char y, char z)
{
super(x,y);
d=z;
}
@Override
public void unfriend()
{
System.out.println("unfriended");
}
}
public static void main (String[] args) throws java.lang.Exception
{
C s = new C(); //error line
s.unfriend();
// your code goes here
}
}
The line marked as error line gives
error: non-static variable this cannot be referenced from a static context C s =new C();
I don't have much clue about this problem, so kindly throw some light on this and its workaround...
This post has been edited by xclite: 08 February 2015 - 12:31 PM
Reason for edit:: Made formatting consistent

New Topic/Question
Reply


MultiQuote





|