63 132
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #12712 in Java | JSP | JSF for Amy

Question #12712
I want to print out two arrays next to each other horizontally, but can only seem to print them one after the other...

System.out.println ( "Customer ID, Transaction Value " );

for (int i = 0; i < customerID.length; i++) {
System.out.println(customerID[i]);
}


for (int i = 0; i < transactionValue.length; i++) {
System.out.println(transactionValue[i]);

I would like them to be like this.

Customer ID, Transaction Value
1, 33.33
2, 44.44
...

Any ideas?
Expert's answer
System.out.println ( "Customer ID, Transaction Value " );
if
(customerID.length==transactionValue.length){
for (int i = 0; i <
customerID.length; i++) {
System.out.print(customerID[i]+"
");
System.out.println(transactionValue[i]);
}
} else
{System.out.println("Lengths of arrays don't match!");}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions