based on array limit
plz guide me how i modify the programm so that the array become dynamic means no need to give its limit.as in this program limit is 5.
its taking input more t 5 but output is applycable for 5 only...
public static void main(String args)
Scanner input=new Scanner(System.in);
int array=new int;
System.out.println("Enter Array Elements: ");
System.out.println("Your Array Elements are: ");
Hi Moni - an array is of fixed length determined when you create it. If you want to have a more flexible structure that will increase its size automatically as you add more inputs, you might want to consider ArrayList. They work just like arrays, except you cannot use them with the primitive types such as int. Hence, there are wrapper classes that can be used to store primitives in ArrayLists. The constructor is:
To access an element at index 2, for example, you will do:
ArrayList<Integer> array = new ArrayList<Integer>();
For a complete method listing, please see the Java Api : ArrayList (Java Platform SE 6)