Помогите разобраться почему не получается создать объект triangle.
Компилятор ругается на 25 строку: non-static variable this cannot be referenced from a static context
package com.javarush.task.task04.task0415;
/*
Правило треугольника
*/
import java.io.*;
import java.lang.annotation.Documented;
public class Solution {
public static void main(String[] args) throws Exception {
//напишите тут ваш код
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String n1 = reader.readLine();
String n2 = reader.readLine();
String n3 = reader.readLine();
int a = Integer.parseInt(n1);
int b = Integer.parseInt(n2);
int c = Integer.parseInt(n3);
String y = "Треугольник существует.";
String n = "Треугольник не существует.";
Triangle triangle = new Triangle(a,b,c);
if (triangle.exist(a,b,c))
System.out.println(y);
else
System.out.println(n);
}
public class Triangle {
int a1;
int a2;
int a3;
public Triangle(int a1, int a2, int a3) {
this.a1 = a1;
this.a2 = a2;
this.a3 = a3;
}
public boolean exist(int a1, int a2, int a3) {
if ((a1 + a2 > a3) && (a1 + a3 > a2) && (a2 + a3 > a1))
return true;
else
return false;
}
}
}