• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Array Data Print Out

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic