I have written a program which uses Arrays. Here is the code of the program...
when i check the output....it gives me bicycle,mango,grapes and pineapple
here is the code snippet.......
public class FruitArray
{
String fruit[] = new String[4];
public static void main(String args[])
{
FruitArray f = new FruitArray();
f.amethod();
f.modify();
}
public void amethod()
{
fruit[0] = "Apple";
fruit[1] = "Mango";
fruit[2] = "Grapes";
fruit[3] = "Pineapple";
}
public void modify()
{
fruit[0]="Bicycle";
for(int i=0;i<fruit.length;i++)
{
System.out.println(fruit[i]);
}
}
}
Please explain this behavior...
Jayashree