Results 1 to 9 of 9
Thread: Java question.
- 08-06-2012, 12:12 AM #1
Member
- Join Date
- Jul 2012
- Posts
- 10
- Rep Power
- 0
Java question.
I am trying to uniformly distributed int value as low as 0 and as high as n . Therefore, nextInt(songs.size()) gives you a random index. the size of songs lessens by one each time you add a randomly selected song to newList. I have to account for this each time you generate a random number.
This is code I have.
public int random (int ){
newList = new ArrayList<Mp3>();
nt randomIndex = random.nextInt(songs.size());
if (songs.size() > 0) {
songs.randomSongs = songs.remove(0);
Thanks.
-
Re: Java question.
I'm sorry, what exactly is your question? Can you clarify just where you're stuck for us?
Also, consider making your question heading more informative as well. "Java question" doesn't tell us much of anything other than that you have a Java question -- but we knew that already, else you wouldn't be here.
- 08-06-2012, 01:33 AM #3
Member
- Join Date
- Jul 2012
- Posts
- 10
- Rep Power
- 0
- 08-06-2012, 04:05 AM #4
Member
- Join Date
- Jul 2012
- Posts
- 10
- Rep Power
- 0
Re: Java question.
The code I have posted.
-
Re: Java question.
I think you'll likely get better help if you explain yourself in greater detail. You may be assuming that we can guess more about your problem then we really are able to.
- 08-06-2012, 04:17 AM #6
Member
- Join Date
- Jul 2012
- Posts
- 10
- Rep Power
- 0
Re: Java question.
The shuffle random number has to be low -2 and high as n.
Last edited by immortal; 08-06-2012 at 04:27 AM.
- 08-06-2012, 05:55 AM #7
Re: Java question.
If you are asking how to randomly play a list of songs then yo need to place all the songs in a List, shuffle, remove first song and play it. Repeat until the List is empty. If you want to play the List again but in a different order then you need to create a new List containing all the songs and repeat the process.
- 08-06-2012, 10:35 AM #8
Member
- Join Date
- Jul 2012
- Posts
- 10
- Rep Power
- 0
- 08-07-2012, 03:49 AM #9
Similar Threads
-
Hello I have a question about map java
By yoron1234567 in forum Forum LobbyReplies: 2Last Post: 03-14-2012, 04:14 PM -
Java Question
By Etimer in forum New To JavaReplies: 7Last Post: 02-04-2012, 07:09 AM -
Java Question [Beginner Question]
By joker760 in forum New To JavaReplies: 3Last Post: 12-13-2011, 04:01 PM -
Java question
By TGH in forum New To JavaReplies: 12Last Post: 11-27-2009, 02:05 PM -
question about java rmi
By hakimade in forum Advanced JavaReplies: 1Last Post: 07-01-2009, 07:15 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks