abrar alvi wrote:ok, but while adding the objects i have added it with 1 and 2.... is it not the right way to do??
Matthew Brown wrote:
What are you trying to do?
abrar alvi wrote:I want to add three random numbers from 1 to 6 to the ArrayList....
abrar alvi wrote:ok, but while adding the objects i have added it with 1 and 2.... is it not the right way to do?? if so can you please suggest me with some code...
Matthew Brown wrote:What you're currently doing is picking a random number, converting it to a String, appending "1" and "2" to it (note that it's using String addition - so concatenation - because you've converted it to a String). You're adding all these to a list. Then you're iterating over the list, but each time printing out the entire list (instead of the current element).
Jesper de Jong wrote: What you are doing now obviously is not generating three random numbers.
abrar alvi wrote:i need three consecutive numbers from a single random number
Jesper de Jong wrote:Ok, so does it work now or not, with the latest change that you posted, or do you still have a question?
abrar alvi wrote:* the program stores three consecutive numbers from 1 to 6 in an ArrayList
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
abrar alvi wrote:
Problem: why am i not getting three random numbers...
R. Jain wrote:
abrar alvi wrote:
Problem: why am i not getting three random numbers...
Because you are not printing the three random numbers...
abrar alvi wrote:Go through my code and the program description and help me out to get the required output...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
abrar alvi wrote:so please help and modify the given code...
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |