Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6631695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:34:58+00:00 2026-05-25T22:34:58+00:00

Say you have some tabular data where the datas length can vary, is there

  • 0

Say you have some tabular data where the datas length can vary, is there a provision with the Formatter class to auto adjust the padding?

So instead of this (note column A):

columnA    columnB     
1            34.34          
10            34.34
100            34.34          
1000            34.34

You get this (note column B):

columnA    columnB     
1            34.34          
10           34.34
100          34.34          
1000         34.34

Thus far, i’ve tried this which only simply includes the spaces between %5s %5s, but they are static and do not adjust to produce the results I want. I was under the impression that the 5 in %5s would auto pad 5 spaces

Formatter formatter = new Formatter();
formatter.format("%5s     %5s", columnAdata, columnBdata);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:34:58+00:00Added an answer on May 25, 2026 at 10:34 pm

    It’s definitely possible. The way I know off-hand is to configure a minimum width for data in your first column. To do this you want to make use of the width attribute in conjunction with left-justification (both documented in the Javadoc). Here’s a start for you:

    System.out.printf("%-10d %d%n", 1, 100);
    System.out.printf("%-10d %d%n", 10, 100);
    System.out.printf("%-10d %d%n", 100, 100);
    

    This prints:

    1          100
    10         100
    100        100
    

    The format %-10d %d%n can be explained as follows:

    %-10d: first field
    
        %: start field
        -: left-justify
       10: output a minimum of 10 characters
        d: format as a decimal integer
    
    %d: second field, using defaults for decimal integer
    %n: newline
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say you have some tabular data you want to display, as well as allow
Say I have some code like namespace Portal { public class Author { public
Lets say we have some basic AR model. class User < ActiveRecord::Base attr_accessible :firstname,
I have a web-site that generates some simple tabular data as html tables, many
Say I have some state which the user can toggle, for example [ON] |
Say I have some data like this: number_stream = [0,0,0,7,8,0,0,2,5,6,10,11,10,13,5,0,1,0,...] I want to process
Say I have some special class, WrappedDataTable , and I want to associate each
Say I have some data stored in an audit table, where triggers on the
Lets say I have some random .cs file containing a class with some properties
Let's say I have some Java code: public class SomeClass { static { private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.