toString align problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chen Yang

    toString align problem

    suppose there're three String a[], b[] and c[], the length are not fixed.
    how can i make the format a[] b[] c[] so that three arrays align to the
    left?

    ok, i know it's stupid.. but i don't think using StringTokenizer to
    implement my own format is a good idea... plez help me out, thanks a lot!





  • Glen Herrmannsfeldt

    #2
    Re: toString align problem


    "Chen Yang" <NOSPAM@hotmail .com> wrote in message
    news:IhDpb.2122 2$HZ3.4972052@n ews4.srv.hcvlny .cv.net...[color=blue]
    > suppose there're three String a[], b[] and c[], the length are not fixed.
    > how can i make the format a[] b[] c[] so that three arrays align to the
    > left?
    >
    > ok, i know it's stupid.. but i don't think using StringTokenizer to
    > implement my own format is a good idea... plez help me out, thanks a lot![/color]

    So there are three string arrays, and you want to print in columns?

    Loop through each to find the longest one, then print each followed by
    enough space to make them align.

    I think there is a method in String that will repeat a character some number
    of times.

    -- glen


    Comment

    • nos

      #3
      Re: toString align problem

      be sure to use a font that has equal width characters

      "Glen Herrmannsfeldt" <gah@ugcs.calte ch.edu> wrote in message
      news:_UGpb.1011 48$Tr4.273598@a ttbi_s03...[color=blue]
      >
      > "Chen Yang" <NOSPAM@hotmail .com> wrote in message
      > news:IhDpb.2122 2$HZ3.4972052@n ews4.srv.hcvlny .cv.net...[color=green]
      > > suppose there're three String a[], b[] and c[], the length are not[/color][/color]
      fixed.[color=blue][color=green]
      > > how can i make the format a[] b[] c[] so that three arrays align to the
      > > left?
      > >
      > > ok, i know it's stupid.. but i don't think using StringTokenizer to
      > > implement my own format is a good idea... plez help me out, thanks a[/color][/color]
      lot![color=blue]
      >
      > So there are three string arrays, and you want to print in columns?
      >
      > Loop through each to find the longest one, then print each followed by
      > enough space to make them align.
      >
      > I think there is a method in String that will repeat a character some[/color]
      number[color=blue]
      > of times.
      >
      > -- glen
      >
      >[/color]


      Comment

      Working...