+ 3
What is the use of array in java
i am confused in array
6 Answers
+ 10
JATIN SHARMA
example:
suppose if you want to use 10 num in your program and think you have no array concept then what you did??
you declare 10 int variable and use this variable in your program.
but here the problem is every time you set every variable or access every variable one by one like:
example:
without using array:
int a=10;
int b=20;
int c=30;
...
...
int z=240;
System.out.println(a);
System.out.println(b);
System.out.println(c);
...
...
...
System.out.println(z);
with array:
int array1[]=new int[10];
for(int i=0;i<array.length;i++)
{
array1[i]=i;//or any value
System.out.println(array1[i]);
}
also without array concept some time its create bad complexity trade-off(time-space both)
i think this one help you
+ 9
JATIN SHARMA
welcome
if you find any problem in my explanation please say i will explain again
thank you
ââ
+ 3
array are use in Java like any other programming language to store set of data values in index element and they are mostly use to large set of data. Example students grade, names of student etc
+ 2
thanks asif
+ 1
thanks droftor