Results 1 to 6 of 6
Thread: How increase dynamic array?
- 12-31-2009, 04:51 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 41
- Rep Power
- 0
- 12-31-2009, 08:34 PM #2
If its a dynamic array, then it increases automatically, hence the name 'Dynamic' array.
- 12-31-2009, 10:04 PM #3
Member
- Join Date
- Dec 2009
- Posts
- 41
- Rep Power
- 0
quad64bit, dynamic array, for example such:
Java Code:int a[];
- 12-31-2009, 10:13 PM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,545
- Rep Power
- 11
- 12-31-2009, 11:51 PM #5
Is not a dynamic array. It is just an array. There is no way to expand an array after the fact, you must either copy the contents to a bigger array or pick a different data structure such as ArrayList.Java Code:int a[];
- 01-01-2010, 12:22 AM #6
Java Code:import java.util.Arrays; public class Test { public static void main(String[] args) { int[] values = { 5, 9, 3, 6 }; System.out.println(Arrays.toString(values)); // Add 7 to the array. int[] temp = new int[values.length+1]; System.arraycopy(values, 0, temp, 0, values.length); temp[values.length] = 7; values = temp; System.out.println(Arrays.toString(values)); } }
Similar Threads
-
increase pixel size
By rosh72851 in forum New To JavaReplies: 9Last Post: 07-31-2012, 07:30 PM -
Increase Network Utilization
By Faisal Ahmed in forum NetworkingReplies: 0Last Post: 12-02-2009, 06:32 AM -
May need to scap project again, is there a way to increase connection times?
By mainy in forum New To JavaReplies: 0Last Post: 08-12-2009, 07:42 PM -
why the number will not increase?
By rayda in forum New To JavaReplies: 3Last Post: 03-16-2009, 05:47 AM -
Increase signature length?
By xcallmejudasx in forum Suggestions & FeedbackReplies: 3Last Post: 12-18-2008, 06:04 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks