0
public class artistSearchOop {
    
    public abstract class ArtistTable implements Interface1{
        
        int rowSum;
        int colSum[];
        
        @Override
        public void salesSummary(){
            
            int artistSales [][] = {
                {900000,800000,500000},
                {700000,500000,500000}       
            };
            
            String[] artistNames = {
                "Master KG",
                "DJ B Coffee"
                
            };
            
            colSum[0] = artistSales [0][0]
                    + artistSales [1][0];
            
            colSum[1] = artistSales [0][1]
                    + artistSales [1][1];
            
             }
        
    }
    
    public interface Interface1 {
        
        public void salesSummary();
            
        
    }
    
    public static void main(String[] args) {
        
        Interface1 interface1 = new ArtistTable();
        interface1.salesSummary();
    }

I keep getting the error "non static variable this cannot be referenced from a static context. On the 3rd last line - 'Interface1 interface1 = new ArtistTable();'

user207421
  • 305,947
  • 44
  • 307
  • 483
  • You're running into this due to using nested types. I *strongly* advise you to use top-level types (i.e. not declare one type within another) unless you really, really know what you're doing and *definitely* want to use a nested type. – Jon Skeet Jun 12 '22 at 06:55
  • When you get an error, try searching stack overflow for the error message before posting -- you will save yourself some time. – tgdavies Jun 12 '22 at 06:55
  • 2
    @tgdavies: No, that question isn't really the same. That question has nothing to do with nested types, whereas the *only* problem in this question is that the types are nested. – Jon Skeet Jun 12 '22 at 06:55

0 Answers0