File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes help with arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help with arrays" Watch "help with arrays" New topic

help with arrays

M Mangion

Joined: Jun 06, 2011
Posts: 11

I have an array which stores info about 20 teams. I created another array which stores the exact info of the first array but the teams are shuffled. I also have a third array this time of 10 which is being used to store matches i.e. 10 matches between the 20 teams.

Now for the matches, I have a class which has the following constructor:

Now for the left and right team I want to pass the [0] and [1] from the shuffled array for match 1, [2] and [3] for match 2 etc.

So to populate the Match array I am trying to use the following code:

However, the system.out statement is not being displayed in the console. Any ideas what I am doing wrong?
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

when all else fails, pepper your code with more println statements. I have been known to put "entering method X" and "leaving method X" in every single method in my code to make sure methods I think are being called really are.

Once you are SURE that method is called, put on as the first thing in your loop: "entering the loop now!"

print your conditions, print when you increment your counters, etc.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
John Jai

Joined: May 31, 2011
Posts: 1776
And check if size of mt is not 10. I see you are saying you have an array of size 10 to hold the matches. Then below will give exception when i in for is going beyond 10.
M Mangion

Joined: Jun 06, 2011
Posts: 11
thank you for your replies. Regarding the loop going beyond 10, you were right and i changed it as follows:

However, this function is still not running at all, i am not even getting the "Started" print statement. The function the it is being called before it from the main is the following, which is the last thing that it is being run successfully(since the array is being shuffled).

the ft mentioned above is the original array before the teams are being shuffled.

Thank you for any feedback.
M Mangion

Joined: Jun 06, 2011
Posts: 11
the problem seems to be coming from the shuffleTeams method because on line 19 in the above code, I added a simply system.out statement to display that the loop has ended, however not even this print statement is being shown in the console. Therefore the console is just showing the 20 teams shuffled and the program is ending their.

Any feedback would be greatly appreciated, as I cannot understand what I am doing wrong.

Thanks in advance for your help.
I agree. Here's the link:
subject: help with arrays
It's not a secret anymore!