Saturday, 31 August 2013

Making two arrays the same length

Making two arrays the same length

Alright so say I have two arrays, of x length, but to do the programming I
need they have to be the same length. How would I cut the longer array to
the length of the shorter array without knowing the actual length since
its an user input?
ex. int[] one = {1,2,3,4}; int[] two = {1,2,3,4,5,6}; for my purposes I
need to chop array two down to 4 so I can then run my comparison with the
length being the same. so I need to chop two to {1,2,3,4}, but the hitch
is I don't know the length of either of my arrays because its by user
input. Can anyone help? Sorry if the wording is confusing.

No comments:

Post a Comment