Java Question

Status
Not open for further replies.
I have a java question. I have an index value that is used to reference a string in an array. The index value is assigned a random number using Math.Random. That part works fine. I need to later reference the index value from another class. When I try to reference the index from the other class it gives me a value of 0. I can't for the life of me figure out why the value is getting changed back to zero. Here the only code that touches the index variable.


public class Card_Reader {

private int index;

public Card_Reader() {
} // end of constructor

public void select_record()
{
int index = (int)(Math.random() * num_lines);
}//End of get_pin_from_DB

public int get_index()
{
System.out.println("Card_Reader_Index_bottom " + index);
return index;
}
}//End of class

Any ideas on why when I try to reference the get_index() method it reurns a value of zero?

Thanks
 
Status
Not open for further replies.