• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Array Data Print Out

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
"You-all" got any ideas how I can get String array data to print out in columns and rows.
I have been working on assignment one of the cattle drive, and I have this one line that looks like this:
System.out.println(" " + '\t' + args[0] );
When the array is printed, it just "vomits" everything out in one big column. How do I get the String array data to display in columns and rows?
Mark C.
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on how exactly you want! You want all the elements from the array to be printed in columnwise?
The following program takes no. of columns as an argument and prints the elements in the array in that fashion.
Have a look

Siva Prasad
[This message has been edited by Marilyn deQueiroz (edited March 09, 2001).]
 
Mark Covert
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, here is the program as it is so far:
(code deleted by Marilyn to protect future participants)
I have no idea how I would incorporate what you wrote into the code I wrote.
Mark
[This message has been edited by Marilyn deQueiroz (edited March 09, 2001).]
 
Siva Prasad
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I got it!
You mean when you give any value in the commandline, the program should print that value in row-wise hundred times?
<code>
java Hundred 10
output:
10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
</code>
Try using forloop and System.out.print statement instead of System.out.println
I can write the code here but its good if you try it on you own.
try to refer JDK API documentation for help regarding those print methods
cheers
Siva Prasad
[This message has been edited by Siva Prasad (edited March 09, 2001).]
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please note that the assignments from the Cattle Drive should really be discussed in the Cattle Drive forum, so I've moved this thread.
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!