comboy
Instructor
- May 23, 2003
- 226
Hi all just started studying Java and need a little help on arrays.
I'm trying design a program that will allow a user to enter a year (an int variable) and return <=values from two external arrays based on the year.
my arrays are as follows
public static final String[] names = {
"Catherine", "Joe", "Betty", "Dave", "Pete", "Kate", "Sean", "Linda"};
public static final int[] birthyear = {
1976, 1960, 1980, 1979, 1974,
1961, 1940, 1976};
What I really need to know is that when the user enters a year e.g. 1980 how do I get Java to select the third index as a starting point as currently I'm getting out of bounds errors when I try to return the index position based on the year variable as its obviously past the array length of 7.
Thanks in advance
I'm trying design a program that will allow a user to enter a year (an int variable) and return <=values from two external arrays based on the year.
my arrays are as follows
public static final String[] names = {
"Catherine", "Joe", "Betty", "Dave", "Pete", "Kate", "Sean", "Linda"};
public static final int[] birthyear = {
1976, 1960, 1980, 1979, 1974,
1961, 1940, 1976};
What I really need to know is that when the user enters a year e.g. 1980 how do I get Java to select the third index as a starting point as currently I'm getting out of bounds errors when I try to return the index position based on the year variable as its obviously past the array length of 7.
Thanks in advance