0
How can i add an element to an array or increase it's size
I made a decimal to binary converter but I couldn't complete it. how can i complete it in java
2 Answers
+ 4
You have a few options for increasing the arrays size:
* Make the array have a larger size, leaving some spaces empty
* Create a new array of the size you need, then add all the elements of the previous array over to the new array
* Use an arrayList
* Use a Linked List
+ 3
you can declare an array like this?
int [] i = new int [5];
now you can initalize each element
i [0] = 41;
System.out.println (i [0]);
output 41
or you can cast the int to double inside print method
System.out.println (double)i [0]));
output 41.0