Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

how can i represent my array better

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using an array of double in a cli environment, there are many types of double integer stored in it. some are zeros , some are double. My problem is when i am using the following code to represent it , its not aligned properly please help me in this regard. I have attached the output. Thank you .

Capture.jpg
[Thumbnail for Capture.jpg]
this is how it looks like
 
Greenhorn
Posts: 14
Eclipse IDE VI Editor BSD
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

deepak bhai wrote:represent it , its not aligned properly please help me in this regard. ]



A very easy way is to use String.fomat(...) instead of java.lang.DecimalFormat and specify the width and precision

The following code produces an 2x2 array of right aligned float values

 
Ranch Hand
Posts: 86
1
Netbeans IDE Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try:

 
deepak bhai
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you so much for your replies. Your method is working like a charm Souza . thanks Andi.
 
Marshal
Posts: 74359
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a section in the Java Tutorials which I think will help a lot.
reply
    Bookmark Topic Watch Topic
  • New Topic