# How to store values in an integer array

Page 1 of 1

## 3 Replies - 25838 Views - Last Post: 01 October 2007 - 01:51 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=34358&amp;s=2d32f0f2da35a3e47f95241755cd71db&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 quakeworld2007

Reputation: 3
• Posts: 71
• Joined: 28-September 07

# How to store values in an integer array

Posted 30 September 2007 - 06:47 PM

How would I store a and b in an array?

```public class Squared {

public static void main(String args[])
{
int a = 0, b = 0;
for ( int number = 5; number <=10; number++)
{
if (number< 15)
a =  (number );
b= (number * number);

System.out.println(a);

}

}

}
```

This post has been edited by jayman9: 30 September 2007 - 11:31 PM

Is This A Good Question/Topic? 0

## Replies To: How to store values in an integer array

### #2 PennyBoki

• system("revolution");

Reputation: 53
• Posts: 2,335
• Joined: 11-December 06

## Re: How to store values in an integer array

Posted 30 September 2007 - 06:59 PM

Hi there, this may not be a solution you want but it sure uses arrays, so try to consider it carefully. And please use code tags when posting code.

```public class Squared {

public static void main(String args[])
{
int a[]={0,0,0,0,0,0} , b[]={0,0,0,0,0,0};
for ( int number = 5; number <=10; number++)
{

a[number-5] = number;
b[number-5]= (number * number);

System.out.println(a[number-5]);
System.out.println(b[number-5]);

}

}

}
```

This post has been edited by PennyBoki: 30 September 2007 - 07:00 PM

### #3 quakeworld2007

Reputation: 3
• Posts: 71
• Joined: 28-September 07

## Re: How to store values in an integer array

Posted 30 September 2007 - 07:26 PM

what does the -5 stand for?

### #4 PennyBoki

• system("revolution");

Reputation: 53
• Posts: 2,335
• Joined: 11-December 06

## Re: How to store values in an integer array

Posted 01 October 2007 - 01:51 PM

Because in the for loop number starts from 5 and the index of the arrays starts from 0.