Hi! I'm new to Java.
I need to make an array like:
int b[] = {0,1,2,3,4,5,6,7,8,9};
Is it possible to use a loop to generate an array like that?
I don't know if I'm asking the right question, so I will try to explain it:

class test0{
	int a=0;
	public test0(){
		int b[]={
			for(int i=0;i<10;i++){
				a++;
			}
		};
	}
	public static void main(String args[]){
		new test0();
	}
}

Thanks a lot in advance.

It is very possible to create an array that way. You know the array will be of size 10. so you can start off by declaring the the array as that size.
Then run the loop with the counter 'i' you have chosen above and you can set each individual element 'b = i'

Hope that helps

Thank you! Yes that helps! :D
Very nice forum btw.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.