hi
my code is something like this
import java.util.*;
public class b
{static
String a="aa";
static ArrayList list2=new ArrayList();
public static void main(String args[])
{list2.add("gh");
Iterator ix=list2.iterator();
while(ix.hasNext())
{Object o1=ix.next();
String go=(String)o1;
System.out.println(go);
}
}
}
import java.util.*;
import b;
class a
{
public static void main(String[] args)
{
Iterator ix=b.list2.iterator();
while(ix.hasNext())
{Object o1=ix.next();
String go=(String)o1;
System.out.println(go);
}
}
}
when i run a.java it does not show the value of the element of
list2.
if i put list2 in a method in class b and call the method
from class a it works fine.
import java.util.*;
public class b
{static String a="aa";
static ArrayList list2=new ArrayList();
static void show()
{list2.add(a);}}
import java.util.*;
import b;
class a
{
public static void main(String[] args)
{b.show();
Iterator ix=b.list2.iterator();
while(ix.hasNext())
{Object o1=ix.next();
String go=(String)o1;
System.out.println(go);
}
}
}
could you please tell me is there any way by which i can refer to list2 directly from a.java without calling the method show()
actually i am working on chat server application where on the server side elements in list2 are added dynamically.now i want
the list of all the elements currently present in list2
i hope u understand
thanks
ASHEET