reset password
Author Message
Drmea2
Posts: 3
Posted 12:20 May 20, 2016 |

I have used a method to print the randomly generated array, but I don't know how to addd the printed array to the string "array:  " in one row. Can you give me a hint?

jbonil34
Posts: 10
Posted 12:39 May 20, 2016 |

use another method to print the "Array: " part.

Drmea2
Posts: 3
Posted 14:06 May 20, 2016 |

Thank you. I get it.

velder0
Posts: 16
Posted 13:38 May 21, 2016 |

i'm having the same problem. Should I make the methods int[] instead of void and then print the returns in another method to add the "Array:"?

rcamach7
Posts: 31
Posted 14:45 May 21, 2016 |

You could just print out the word "Array: " with a simple println statement and in your void method instead of using println just use print ( as in system.out.print(x) ).

Last edited by rcamach7 at 14:45 May 21, 2016.
velder0
Posts: 16
Posted 15:52 May 21, 2016 |

Yah that's what I'm doing and it prints the array, but do I put the println statement with the Array: in the same void method or in a different one. If i add it to the void one it adds Array to every array output

rcamach7
Posts: 31
Posted 16:20 May 21, 2016 |

Right, just print the "Array: " in main and call your void method in the next line.

Also, if you wanted to do it inside the void method, just make sure the print statement is outside any loops, that's why it prints multiple times for you. If you do it outside any loops or functions it should only print once.

Last edited by rcamach7 at 16:22 May 21, 2016.