Hi, I'm wondering how I can accomplish this.

Suppose I have the following array

String[] randomText = {"hi", "hello", "hey there"}


If I want to print the array I only know how to do so line by line.

for (int num = 0; num < randomText.length; num++){

Can someone point me in the right direction?

Yeah, what exactly do you mean? System.out.println() will print out each element on a new line.. if you use System.out.print(), then you can print each element on the same line..

for (int i = 0; i < randomText.length - 1; i++)
	System.out.print(randomText[i] + " ");
System.out.print(randomText[randomText.length - 1]);
//Prints out randomText[] on one line, delimited by spaces.

It was the System.out.print statement I guess, I missed that hehe.


This question has already been answered. Start a new discussion instead.