public class ProcessResults
{
	private static int[] PayNum;
	private static String[] Surname;
	private static String[] FirstName;
	private static String[] DoB;
	private static String[] Dept;
	private static Scanner keyboard = new Scanner(System.in);
	private static int NumStaff;

	public static void main(String[] args)
	{
		final int MAX_STAFF = 10;
		PayNum = new int[MAX_STAFF];
		Surname = new String[MAX_STAFF];
		FirstName = new String[MAX_STAFF];
		DoB = new String[MAX_STAFF];
		Dept = new String[MAX_STAFF];
		
		
		
		String entry;
		char option;
		NumStaff = 0;

public static void initialiseArray() 
		{
			int [] TempPayNum = {123456, 234567, 345678, 456789, 567890, 678901, 789012}; 
			String[] TempSurname={"Brown", "Jenkins", "Turner", "Cavendish", "Williams", "Ford", "Carter"}; 
			String [] TempFirstName = {"James", "Susan", "Jane", "Paul", "James", "Karen", "Daniel"}; 
			String[] TempDoB ={"24/3/85", "11/12/80", "5/7/72", "22/9/76", "19/1/81", "15/8/79", "4/2/62"};
			String [] TempDept ={"Marketing", "Sales", " Sales", "Accounts", "Marketing", " Sales", "Accounts "};
			 
			for (int i = 0; i < 6;i++)
			{
				PayNum [i] = TempPayNum[i];
				Surname [i] = TempSurname[i];
				FirstName[i]=TempFirstName[i];
				DoB [i]= TempDoB[i];
				Dept[i]=TempDept[i];
				NumStaff++;
				
			}	
		}

ive been trying to print the contents list using different loops but all i get is null, do you have any ideas how i could do this please, your help will be greatly appreciated.

the only bits of missing code is just for the prgram menu i have not uploaded it because that is working fine.

Edited 5 Years Ago by FlavaK: n/a

with a for loop inserted inside your main method I got the following result:

Brown James 123456 24/3/85 Marketing
Jenkins Susan 234567 11/12/80 Sales
Turner Jane 345678 5/7/72 Sales
Cavendish Paul 456789 22/9/76 Accounts
Williams James 567890 19/1/81 Marketing
Ford Karen 678901 15/8/79 Sales

Other than the for loop inserted, I also called first the method initialiseArray() - if you do not call this method first, you ought to get null for the values inside your arrays. I made MAX_STAFF match the actual number of staff you 'construct' in your initialiseArray() method. And, for that code you offered, the variable NumStaff remains unreferenced, thus unnecessary. Hope this helps.

with a for loop inserted inside your main method I got the following result:

Brown James 123456 24/3/85 Marketing
Jenkins Susan 234567 11/12/80 Sales
Turner Jane 345678 5/7/72 Sales
Cavendish Paul 456789 22/9/76 Accounts
Williams James 567890 19/1/81 Marketing
Ford Karen 678901 15/8/79 Sales

Other than the for loop inserted, I also called first the method initialiseArray() - if you do not call this method first, you ought to get null for the values inside your arrays. I made MAX_STAFF match the actual number of staff you 'construct' in your initialiseArray() method. And, for that code you offered, the variable NumStaff remains unreferenced, thus unnecessary. Hope this helps.

thanks for the reply i just tried and im either doing something wrong (still a javan oob) would you show me the implemented code so that i can try it out myself if you can please?

with the code you have posted here, I do not know how come you get null printed out. you do not have any System.out.println() or anything in your code. I assume you have some other code.

Anyways, it is a norm to help people in Daniweb but not to their work. However, what I am saying should be very simple to implement:
1. no method can be defined inside the main method. you are doing this wrong building inigtializeArray() inside main.
2.once you correct that, you call initializeArray() inside your main method.(no modification required on your initializeArray method's code)
3. you write a loop to loop through the arrays whose values you want printed on your screen (Surname, Firstname, DoB, Dept).

it is easy to do this if you try to.

with the code you have posted here, I do not know how come you get null printed out. you do not have any System.out.println() or anything in your code. I assume you have some other code.

Anyways, it is a norm to help people in Daniweb but not to their work. However, what I am saying should be very simple to implement:
1. no method can be defined inside the main method. you are doing this wrong building inigtializeArray() inside main.
2.once you correct that, you call initializeArray() inside your main method.(no modification required on your initializeArray method's code)
3. you write a loop to loop through the arrays whose values you want printed on your screen (Surname, Firstname, DoB, Dept).

it is easy to do this if you try to.

thanks ive managed to sort it out

This article has been dead for over six months. Start a new discussion instead.