Take a look at this code :
import java.awt.*;
public class StupidStuff
{
final static Polygon poly=new Polygon(new int[]{1,2,3},new int[]{1,2,3},3);
public static void main(String args[])
{
for(int i=1;i<=2;i++)
{
System.out.println("-----"+i+"-----");
StupidFunction();
}
}
static void StupidFunction()
{
Polygon p=new Polygon();
p=poly;
for(int j=0;j<p.npoints;j++)
{
p.xpoints[j]=p.xpoints[j]+1;
System.out.println(p.xpoints[j]);
}
}
}
I don’t understand why the output it’s 2,3,4 and 3,4,5 instead of 2,3,4 and 2,3,4. ??? Why the second time p=poly; it’s not working well ? Help please 