• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to print all Numbers of Array in java?

 
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there

This is my code



and i am getting this output


----------
! 1712 !2156|
----------
! 1713 !4583|
----------
! 1714 !3981|
----------

[HENRY: 6000+ LINES DELETED -- Isn't it a bit ridiculous hard to read when you flood a post with thousands of output lines?]

----------
! 4998 !3094|
----------
! 4999 !836|
----------
12:10:56




I am expecting Number to be print from Index ) but they are not printing ,why?

If I use arraysize like 2000 I am getting all number starting from 0 to 1999

why?

Thanks
 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They are printing but output is too large therefore it override previous output and start displaying from 1712 !2156|
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply

I am using Eclipse



Which tool or Ide I should use to view all numbers?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kishor Joshi wrote:
Which tool or Ide I should use to view all numbers?



Isn't it easier to just redirect standard output to a file? Practically all command windows (or tool output windows) will truncate -- or it can theoretically run out of memory holding all that history.

Henry
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is simply a formatting problem. Find out how to format your output with the % tags. You can find out about that in the Formatter class and in several places in the Java Tutorials: 1 2 3. No 3 is about formatting classes like DecimalFormat, so use no 1 + 2.
Also avoid multiple print instructions. If you can join the three instructions in lines 34‑36 into one instruction you can probably improve performance. Maybe only by a few milliseconds, but in 5000 lines that makes several seconds.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kishor Joshi wrote:If I use arraysize like 2000 I am getting all number starting from 0 to 1999
why?


Erm...because that's what you've coded?

Arrays have a fixed size - which you appear to have redundantly assigned to arraySize - and a generic "print" method can't possibly know what portion of that array contains the things you want to display unless you tell it.

A List, on the other hand, contains only as many elements as you've supplied to it, so it will only print out that many.

So maybe the answer is to use a List, rather than an array.

Winston
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic