3 Replies - 357 Views - Last Post: 02 April 2013 - 07:40 PM Rate Topic: -----

#1 totmore  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 31-March 13

I want to apply currency format to my 2 dimensional array?

Posted 02 April 2013 - 04:03 PM

I want to apply currency format to all the columns to my 2 dimensional array except the first column?
this code prints my array on the console with a currency format, How do i code it so it won't print currency format to my first column but on every thing else??
for (int i = 0; i < salesArray.length; i++)
        {
            for (int j = 0; j < salesArray[i].length; j++)
                System.out.print( "    " + currency.format(salesArray[i][j]));
            
            System.out.print("\n");
        }


Is This A Good Question/Topic? 0
  • +

Replies To: I want to apply currency format to my 2 dimensional array?

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10821
  • View blog
  • Posts: 40,341
  • Joined: 27-December 08

Re: I want to apply currency format to my 2 dimensional array?

Posted 02 April 2013 - 04:09 PM

Start j at 1 rather than 0.
Was This Post Helpful? 0
  • +
  • -

#3 totmore  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 31-March 13

Re: I want to apply currency format to my 2 dimensional array?

Posted 02 April 2013 - 04:19 PM

But that will just print out my array without the first column, I want to keep the column just not currency formatted like the others?
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8347
  • View blog
  • Posts: 31,913
  • Joined: 06-March 08

Re: I want to apply currency format to my 2 dimensional array?

Posted 02 April 2013 - 07:40 PM

View Posttotmore, on 02 April 2013 - 07:19 PM, said:

But that will just print out my array without the first column, I want to keep the column just not currency formatted like the others?

Just use a bit of imagination :)

for (int i = 0; i < salesArray.length; i++)
        {
            System.out.print( "    " + salesArray[i][0]);
            for (int j = 1; j < salesArray[i].length; j++)
                System.out.print( "    " + currency.format(salesArray[i][j]));
            
            System.out.print("\n");
        }


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1