handle array of numbers

 DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

# Thread: handle array of numbers

1. Registered User
Join Date
Oct 2010
Posts
1

## handle array of numbers

If you have an array of numbers like (00,245,34,675,109) and i want to put it in 2 dimensional array so that each number would be in an array and how can i perform it so that it the units would be in the last cell following by the tenth till the end

MANY THANKS FOR CONSIDERATION

2. Registered User
Join Date
Oct 2010
Posts
10

## check this out :solution to your problem

Code:
```class demoArray
{
public static void main (String args[])
{
int ary[]={0,245,34,675,109};
int ary2[][]=new int[5][3];
//int ary2[][]=new int[][] {{1,0,0},{0,1,0},{1,2,1}};

for(int i=0;i<ary.length;i++)
{
int j=ary[i];
if(j==0)
{
for(int x=0;x<ary2[i].length;x++)
ary2[i][x]=0;
}

else
{
int x=ary2[i].length-1;

while(j>=0 && x>=0)
{
int r;
r=j%10;
j=j/10;
ary2[i][x]=r;
x--;

}
}
}
for (int i=0;i<=ary.length;i++)
{
for(int j=0;j<ary2[i].length;j++)
System.out.print(" "+ary2[i][j]);
System.out.println();
}

}
}```

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 FAQ Latest Articles Java .NET XML Database Enterprise