I have a String
array like below:
String[] titles = new String[] { "Booking", "Entry", "Type",
"Duration", "Status", "Contract ID",
"Capacity", "Start Day", "End Day", "Source Ref" };
I need to append, some more values to this array at later state, like below:
titles = new String[] { "Booking", "Shipper", "Booking Quantity", "Entry",
"Type", "Duration", "Status",
"Contract ID", "Capacity", "Start Day",
"End Day", "Source Ref" };
here I added "Shipper", "Booking Quantity"
to the first array.
Is there any way to append those values based on index or any way, without creating like above example? (Is it possible?)
when you initialize an array like this
String[] titles = new String[] { "Booking", "Entry", "Type",
"Duration", "Status", "Contract ID",
"Capacity", "Start Day", "End Day", "Source Ref" };
Property of array "once you initialize the array after that you can't change the size of array"*
so in your case you must initialize new array ....
Or you can use ArrayList
and with its add(index, value)
method you can add your value at your required
position ..
But implicit it also use Concept of Dynamic Array..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With