I want to make a table as an attribute and retrieving it was successful but it comes with an error
public class Main {
public static class stock {
public int n;
public int t[];
public stock(int n)
{
t=new int[n];
}
public void display()
{
for(int i:t)
{
System.out.print(i+" ");
}
}
}
public static void main(String[] args) {
stock s=new stock(4);
stock c[] =new stock[4];
for(int j=0;j<2;j++)
{
for(int i=0;i<4;i++)
{
s.t[i]=i;
}
c[j]=s;
}
for(stock x:c)
x.display();
}
}
this is the result with an error how can i get rid of it
where is the problem
1