here i want to use the arraylist arrc in another method choosec. In the highlighted line in choosec method when use call in this way then it call the method addc() once again and i have to give input for it once again. I don't want this to happen. I just want the data of arrc.
/*code starts here*/
public void addc()
{
ArrayList<Hashtable> arrc = new ArrayList<Hashtable>();
Hashtable<String, String> nr = new Hashtable<String, String>();
Hashtable<String, Float> nc = new Hashtable<String, Float>();
Hashtable<String, Integer> nl = new Hashtable<String, Integer>();
Scanner sc = new Scanner(System.in);
System.out.print("name:-");
String cname = sc.nextLine();
System.out.print("role:-");
String role = sc.nextLine();
System.out.print("ctc:-");
int ctc = sc.nextInt();
System.out.print("mincg:-");
double mincg = sc.nextFloat();
nr.put(cname, role);
nl.put(cname, ctc);
nc.put(cname, (float) mincg);
arrc.add(nr);
arrc.add(nl);
arrc.add(nc);
}
public void choosec(company c)
{
System.out.println("1). "+ arrc.get(0).keySet()); // wants to print out the key **cname** here but it shows an error on **arrc**.
}