Hi, I have a Question regarding the Arrays. I am new and trying to understand how Arrays works.
When I am reading some material it Says that I need to create an Array like below
Code with using NEW
===================
Note: Here they used NEW
String[] anArray = new String[5];
for (int i=0; i<5; i++)
{
//Asigned dat to the Array
}
Code with OUT using NEW
=====================
public class myArray{
public static void main(String[] args)
{
String[] anArray = {"String one","String Two","String Three" };
}
}
In the just above exanple in the line
String[] anArray = {"String one","String Two","String
the Array anArray is not creted using NEW Keyword...
Can you pl explain me why sometimes NEW and SOmetimed not ?
Appreciate your Time
When I am reading some material it Says that I need to create an Array like below
Code with using NEW
===================
Note: Here they used NEW
String[] anArray = new String[5];
for (int i=0; i<5; i++)
{
//Asigned dat to the Array
}
Code with OUT using NEW
=====================
public class myArray{
public static void main(String[] args)
{
String[] anArray = {"String one","String Two","String Three" };
}
}
In the just above exanple in the line
String[] anArray = {"String one","String Two","String
the Array anArray is not creted using NEW Keyword...
Can you pl explain me why sometimes NEW and SOmetimed not ?
Appreciate your Time