Мой первый блок кода - мой объектный файл.второй - это основной класс.До этого не было никаких проблем с выполнением кода, но после того, как я добавил файл для чтения и записи, мой код начал получать ошибку потока стека.только фрагмент, из которого вызывается ошибка.
public class Item implements java.io.Serializable {
public static String name;
public static double price;
public static double amount;
public int max = 1;
SlayerProgram sp = new SlayerProgram();
ReadFile rf = new ReadFile();
public Item(String name, double price,double amount )
{
this.name = name;
this.price = price;
this.amount = amount;
}
public void ItemSet(String name, double price,double amount)
{
this.name = name;
this.price = price;
this.amount = amount
}
Мой основной класс:
public class SlayerProgram {
//import file txts, and Item Class
static String name;
static double price;
static double amount;
Item item = new Item(name,price,amount);
ReadFile rf = new ReadFile();
static String fileNameText = "D:\\Game\\SlayerProgram\\Name.txt";
static String filePriceInt = "D:\\Game\\SlayerProgram\\Price.txt";
static String fileAmountInt ="D:\\Game\\SlayerProgram\\Amount.txt";
//begin file Read
public void BeginText() throws IOException
{
TextFile();
}
public void Max()
{
item.Max();
}
//declare needed Data Types;
final int max = item.max;
ArrayList<String> Name = new ArrayList<>();
ArrayList<Double> Price = new ArrayList<>();
double size = Price.size();
ArrayList<Double> Amount = new ArrayList<>();
Exception in thread "main" java.lang.StackOverflowError
at slayerprogram.Item.<init>(Item.java:18)
at slayerprogram.SlayerProgram.<init>(SlayerProgram.java:25)
at slayerprogram.Item.<init>(Item.java:18)
at slayerprogram.SlayerProgram.<init>(SlayerProgram.java:25)
Как найти причину переполнения стека?