How can I put two or more arrays into a single array?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I want to take the values of the three arrays put them together into one array and output it but I have no idea how to do this. I would appreciate any answers to lead me in the right direction.
// num is user entered as number of times to output
int skuNum = new int[num];
int letters = new int[4];
int l_p_Num = new int[4];
int count = 1;
// Fill numbers array
for (int s: skuNum) {
System.out.print(String.format("%05d", (s + count)) + " ");
count++;
// Fill letters array
for(int i: letters) {
i = (rnd.nextInt(26) + 'A');
System.out.print((char)i);
}
System.out.print(" ");
for(int q: l_p_Num) {
q = rnd.nextInt(9) + 0;
System.out.print(q);
}
System.out.println();
}
java arrays
add a comment |
I want to take the values of the three arrays put them together into one array and output it but I have no idea how to do this. I would appreciate any answers to lead me in the right direction.
// num is user entered as number of times to output
int skuNum = new int[num];
int letters = new int[4];
int l_p_Num = new int[4];
int count = 1;
// Fill numbers array
for (int s: skuNum) {
System.out.print(String.format("%05d", (s + count)) + " ");
count++;
// Fill letters array
for(int i: letters) {
i = (rnd.nextInt(26) + 'A');
System.out.print((char)i);
}
System.out.print(" ");
for(int q: l_p_Num) {
q = rnd.nextInt(9) + 0;
System.out.print(q);
}
System.out.println();
}
java arrays
How are you going to order the values in the new array? Just put all of one array's values in then the next array, then the 3rd?
– Ryan Wilson
Nov 16 '18 at 20:51
What I want is to have a new array with the three arrays values in an index. What I have will give me 00001 DVAH 4238. 00001 is in the first array, DVAH in the second, and 4238 in the third. What I now want is 00001 DVAH 4238 in a single array.
– J J
Nov 16 '18 at 20:53
3
What does that mean??
– shmosel
Nov 16 '18 at 20:53
Have a look at my answer :)
– Emanuel Graf
Nov 16 '18 at 21:10
add a comment |
I want to take the values of the three arrays put them together into one array and output it but I have no idea how to do this. I would appreciate any answers to lead me in the right direction.
// num is user entered as number of times to output
int skuNum = new int[num];
int letters = new int[4];
int l_p_Num = new int[4];
int count = 1;
// Fill numbers array
for (int s: skuNum) {
System.out.print(String.format("%05d", (s + count)) + " ");
count++;
// Fill letters array
for(int i: letters) {
i = (rnd.nextInt(26) + 'A');
System.out.print((char)i);
}
System.out.print(" ");
for(int q: l_p_Num) {
q = rnd.nextInt(9) + 0;
System.out.print(q);
}
System.out.println();
}
java arrays
I want to take the values of the three arrays put them together into one array and output it but I have no idea how to do this. I would appreciate any answers to lead me in the right direction.
// num is user entered as number of times to output
int skuNum = new int[num];
int letters = new int[4];
int l_p_Num = new int[4];
int count = 1;
// Fill numbers array
for (int s: skuNum) {
System.out.print(String.format("%05d", (s + count)) + " ");
count++;
// Fill letters array
for(int i: letters) {
i = (rnd.nextInt(26) + 'A');
System.out.print((char)i);
}
System.out.print(" ");
for(int q: l_p_Num) {
q = rnd.nextInt(9) + 0;
System.out.print(q);
}
System.out.println();
}
java arrays
java arrays
asked Nov 16 '18 at 20:47
J JJ J
83
83
How are you going to order the values in the new array? Just put all of one array's values in then the next array, then the 3rd?
– Ryan Wilson
Nov 16 '18 at 20:51
What I want is to have a new array with the three arrays values in an index. What I have will give me 00001 DVAH 4238. 00001 is in the first array, DVAH in the second, and 4238 in the third. What I now want is 00001 DVAH 4238 in a single array.
– J J
Nov 16 '18 at 20:53
3
What does that mean??
– shmosel
Nov 16 '18 at 20:53
Have a look at my answer :)
– Emanuel Graf
Nov 16 '18 at 21:10
add a comment |
How are you going to order the values in the new array? Just put all of one array's values in then the next array, then the 3rd?
– Ryan Wilson
Nov 16 '18 at 20:51
What I want is to have a new array with the three arrays values in an index. What I have will give me 00001 DVAH 4238. 00001 is in the first array, DVAH in the second, and 4238 in the third. What I now want is 00001 DVAH 4238 in a single array.
– J J
Nov 16 '18 at 20:53
3
What does that mean??
– shmosel
Nov 16 '18 at 20:53
Have a look at my answer :)
– Emanuel Graf
Nov 16 '18 at 21:10
How are you going to order the values in the new array? Just put all of one array's values in then the next array, then the 3rd?
– Ryan Wilson
Nov 16 '18 at 20:51
How are you going to order the values in the new array? Just put all of one array's values in then the next array, then the 3rd?
– Ryan Wilson
Nov 16 '18 at 20:51
What I want is to have a new array with the three arrays values in an index. What I have will give me 00001 DVAH 4238. 00001 is in the first array, DVAH in the second, and 4238 in the third. What I now want is 00001 DVAH 4238 in a single array.
– J J
Nov 16 '18 at 20:53
What I want is to have a new array with the three arrays values in an index. What I have will give me 00001 DVAH 4238. 00001 is in the first array, DVAH in the second, and 4238 in the third. What I now want is 00001 DVAH 4238 in a single array.
– J J
Nov 16 '18 at 20:53
3
3
What does that mean??
– shmosel
Nov 16 '18 at 20:53
What does that mean??
– shmosel
Nov 16 '18 at 20:53
Have a look at my answer :)
– Emanuel Graf
Nov 16 '18 at 21:10
Have a look at my answer :)
– Emanuel Graf
Nov 16 '18 at 21:10
add a comment |
4 Answers
4
active
oldest
votes
You can use:
int arrays = {skuNum, letters, l_p_Num};
or
int arrays = new int {skuNum, letters, l_p_Num};
to create array of arrays and iterate through each array with for loops:
for (int i = 0; i < arrays .length; i++) {
// each array from arrays
for (int j = 0; j < arrays [i].length; j++) {
//each int value from each array
System.out.println(arrays[i][j]);
}
}
To display the result in your "00001 DVAH 4238" format
for (int i=0; i<skuNum.length; i++) {
String row = String.valueOf(skuNum[i]) + String.valueOf(letters[i]) + String.valueOf(l_p_Num[i]);
System.out.println(row);
}
This worked for me but I'm still a beginner so I don't know what exactly I have to do to get rid of this: [I@6bdf28bb [I@6b71769e [I@2752f6e2
– J J
Nov 16 '18 at 21:05
I added an example to display result in your custom format
– Centos
Nov 16 '18 at 22:00
add a comment |
A possible java 8 solution is the following:
int skuNum = new int[num];
int letters = new int {1, 2, 3, 4};
int l_p_Num = new int {11, 12, 13, 14};
IntStream joined = IntStream.concat(IntStream.concat(IntStream.of(skuNum), IntStream.of(letters)), IntStream.of(l_p_Num));
System.out.println(joined
.boxed()
.map(String::valueOf)
.collect(Collectors.joining(",")));
add a comment |
Declare a new int
array to hold all the numbers and then use System.arraycopy()
to copy the smaller arrays into the result
array:
int skuNum = new int[num]; // 1, 2
int letters = new int[4]; // 4, 5, 6, 7
int l_p_Num = new int[4]; // 9, 8, 7, 6
int result = new int[num + 8];
System.arraycopy(skuNum, 0, result, 0, num);
System.arraycopy(letters, 0, result, num, 4);
System.arraycopy(l_p_Num, 0, result, num + 4, 4);
System.out.println(Arrays.toString(result));
will output:
[1, 2, 4, 5, 6, 7, 9, 8, 7, 6]
1
All that'll give is 0's
– J J
Nov 16 '18 at 20:59
add a comment |
So this is without the Java generics, just with for loops
int skuNum = {1,2,3};
int letters = {4,5,6};
int l_p_Num = {7,8,9};
int finalInt = new int[skuNum.length+letters.length+l_p_Num.length];
for (int i = 0; i<skuNum.length;i++) {
finalInt[i] =skuNum[i];
}
for (int i = 0; i<letters.length;i++) {
finalInt[i+skuNum.length] =letters[i];
}
for (int i = 0; i<l_p_Num.length;i++) {
finalInt[i+skuNum.length+letters.length] =l_p_Num[i];
}
for (int i : finalInt)
System.out.print(i);
Result:
123456789
If you want to have strings in it see this code:
int skuNum = {1,2,3};
String letters = {"asd","asd","aefuh"};
int l_p_Num = {7,8,9};
String finalArray = new String[skuNum.length+letters.length+l_p_Num.length];
for (int i = 0; i<skuNum.length;i++) {
finalArray[i] =String.valueOf(skuNum[i]);
}
for (int i = 0; i<letters.length;i++) {
finalArray[i+skuNum.length] =letters[i];
}
for (int i = 0; i<l_p_Num.length;i++) {
finalArray[i+skuNum.length+letters.length] = String.valueOf(l_p_Num[i]);
}
for (String st : finalArray)
System.out.print(st);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53345164%2fhow-can-i-put-two-or-more-arrays-into-a-single-array%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use:
int arrays = {skuNum, letters, l_p_Num};
or
int arrays = new int {skuNum, letters, l_p_Num};
to create array of arrays and iterate through each array with for loops:
for (int i = 0; i < arrays .length; i++) {
// each array from arrays
for (int j = 0; j < arrays [i].length; j++) {
//each int value from each array
System.out.println(arrays[i][j]);
}
}
To display the result in your "00001 DVAH 4238" format
for (int i=0; i<skuNum.length; i++) {
String row = String.valueOf(skuNum[i]) + String.valueOf(letters[i]) + String.valueOf(l_p_Num[i]);
System.out.println(row);
}
This worked for me but I'm still a beginner so I don't know what exactly I have to do to get rid of this: [I@6bdf28bb [I@6b71769e [I@2752f6e2
– J J
Nov 16 '18 at 21:05
I added an example to display result in your custom format
– Centos
Nov 16 '18 at 22:00
add a comment |
You can use:
int arrays = {skuNum, letters, l_p_Num};
or
int arrays = new int {skuNum, letters, l_p_Num};
to create array of arrays and iterate through each array with for loops:
for (int i = 0; i < arrays .length; i++) {
// each array from arrays
for (int j = 0; j < arrays [i].length; j++) {
//each int value from each array
System.out.println(arrays[i][j]);
}
}
To display the result in your "00001 DVAH 4238" format
for (int i=0; i<skuNum.length; i++) {
String row = String.valueOf(skuNum[i]) + String.valueOf(letters[i]) + String.valueOf(l_p_Num[i]);
System.out.println(row);
}
This worked for me but I'm still a beginner so I don't know what exactly I have to do to get rid of this: [I@6bdf28bb [I@6b71769e [I@2752f6e2
– J J
Nov 16 '18 at 21:05
I added an example to display result in your custom format
– Centos
Nov 16 '18 at 22:00
add a comment |
You can use:
int arrays = {skuNum, letters, l_p_Num};
or
int arrays = new int {skuNum, letters, l_p_Num};
to create array of arrays and iterate through each array with for loops:
for (int i = 0; i < arrays .length; i++) {
// each array from arrays
for (int j = 0; j < arrays [i].length; j++) {
//each int value from each array
System.out.println(arrays[i][j]);
}
}
To display the result in your "00001 DVAH 4238" format
for (int i=0; i<skuNum.length; i++) {
String row = String.valueOf(skuNum[i]) + String.valueOf(letters[i]) + String.valueOf(l_p_Num[i]);
System.out.println(row);
}
You can use:
int arrays = {skuNum, letters, l_p_Num};
or
int arrays = new int {skuNum, letters, l_p_Num};
to create array of arrays and iterate through each array with for loops:
for (int i = 0; i < arrays .length; i++) {
// each array from arrays
for (int j = 0; j < arrays [i].length; j++) {
//each int value from each array
System.out.println(arrays[i][j]);
}
}
To display the result in your "00001 DVAH 4238" format
for (int i=0; i<skuNum.length; i++) {
String row = String.valueOf(skuNum[i]) + String.valueOf(letters[i]) + String.valueOf(l_p_Num[i]);
System.out.println(row);
}
edited Nov 16 '18 at 21:46
answered Nov 16 '18 at 20:58
CentosCentos
200110
200110
This worked for me but I'm still a beginner so I don't know what exactly I have to do to get rid of this: [I@6bdf28bb [I@6b71769e [I@2752f6e2
– J J
Nov 16 '18 at 21:05
I added an example to display result in your custom format
– Centos
Nov 16 '18 at 22:00
add a comment |
This worked for me but I'm still a beginner so I don't know what exactly I have to do to get rid of this: [I@6bdf28bb [I@6b71769e [I@2752f6e2
– J J
Nov 16 '18 at 21:05
I added an example to display result in your custom format
– Centos
Nov 16 '18 at 22:00
This worked for me but I'm still a beginner so I don't know what exactly I have to do to get rid of this: [I@6bdf28bb [I@6b71769e [I@2752f6e2
– J J
Nov 16 '18 at 21:05
This worked for me but I'm still a beginner so I don't know what exactly I have to do to get rid of this: [I@6bdf28bb [I@6b71769e [I@2752f6e2
– J J
Nov 16 '18 at 21:05
I added an example to display result in your custom format
– Centos
Nov 16 '18 at 22:00
I added an example to display result in your custom format
– Centos
Nov 16 '18 at 22:00
add a comment |
A possible java 8 solution is the following:
int skuNum = new int[num];
int letters = new int {1, 2, 3, 4};
int l_p_Num = new int {11, 12, 13, 14};
IntStream joined = IntStream.concat(IntStream.concat(IntStream.of(skuNum), IntStream.of(letters)), IntStream.of(l_p_Num));
System.out.println(joined
.boxed()
.map(String::valueOf)
.collect(Collectors.joining(",")));
add a comment |
A possible java 8 solution is the following:
int skuNum = new int[num];
int letters = new int {1, 2, 3, 4};
int l_p_Num = new int {11, 12, 13, 14};
IntStream joined = IntStream.concat(IntStream.concat(IntStream.of(skuNum), IntStream.of(letters)), IntStream.of(l_p_Num));
System.out.println(joined
.boxed()
.map(String::valueOf)
.collect(Collectors.joining(",")));
add a comment |
A possible java 8 solution is the following:
int skuNum = new int[num];
int letters = new int {1, 2, 3, 4};
int l_p_Num = new int {11, 12, 13, 14};
IntStream joined = IntStream.concat(IntStream.concat(IntStream.of(skuNum), IntStream.of(letters)), IntStream.of(l_p_Num));
System.out.println(joined
.boxed()
.map(String::valueOf)
.collect(Collectors.joining(",")));
A possible java 8 solution is the following:
int skuNum = new int[num];
int letters = new int {1, 2, 3, 4};
int l_p_Num = new int {11, 12, 13, 14};
IntStream joined = IntStream.concat(IntStream.concat(IntStream.of(skuNum), IntStream.of(letters)), IntStream.of(l_p_Num));
System.out.println(joined
.boxed()
.map(String::valueOf)
.collect(Collectors.joining(",")));
edited Nov 16 '18 at 21:26
answered Nov 16 '18 at 21:09
yaccobyaccob
668611
668611
add a comment |
add a comment |
Declare a new int
array to hold all the numbers and then use System.arraycopy()
to copy the smaller arrays into the result
array:
int skuNum = new int[num]; // 1, 2
int letters = new int[4]; // 4, 5, 6, 7
int l_p_Num = new int[4]; // 9, 8, 7, 6
int result = new int[num + 8];
System.arraycopy(skuNum, 0, result, 0, num);
System.arraycopy(letters, 0, result, num, 4);
System.arraycopy(l_p_Num, 0, result, num + 4, 4);
System.out.println(Arrays.toString(result));
will output:
[1, 2, 4, 5, 6, 7, 9, 8, 7, 6]
1
All that'll give is 0's
– J J
Nov 16 '18 at 20:59
add a comment |
Declare a new int
array to hold all the numbers and then use System.arraycopy()
to copy the smaller arrays into the result
array:
int skuNum = new int[num]; // 1, 2
int letters = new int[4]; // 4, 5, 6, 7
int l_p_Num = new int[4]; // 9, 8, 7, 6
int result = new int[num + 8];
System.arraycopy(skuNum, 0, result, 0, num);
System.arraycopy(letters, 0, result, num, 4);
System.arraycopy(l_p_Num, 0, result, num + 4, 4);
System.out.println(Arrays.toString(result));
will output:
[1, 2, 4, 5, 6, 7, 9, 8, 7, 6]
1
All that'll give is 0's
– J J
Nov 16 '18 at 20:59
add a comment |
Declare a new int
array to hold all the numbers and then use System.arraycopy()
to copy the smaller arrays into the result
array:
int skuNum = new int[num]; // 1, 2
int letters = new int[4]; // 4, 5, 6, 7
int l_p_Num = new int[4]; // 9, 8, 7, 6
int result = new int[num + 8];
System.arraycopy(skuNum, 0, result, 0, num);
System.arraycopy(letters, 0, result, num, 4);
System.arraycopy(l_p_Num, 0, result, num + 4, 4);
System.out.println(Arrays.toString(result));
will output:
[1, 2, 4, 5, 6, 7, 9, 8, 7, 6]
Declare a new int
array to hold all the numbers and then use System.arraycopy()
to copy the smaller arrays into the result
array:
int skuNum = new int[num]; // 1, 2
int letters = new int[4]; // 4, 5, 6, 7
int l_p_Num = new int[4]; // 9, 8, 7, 6
int result = new int[num + 8];
System.arraycopy(skuNum, 0, result, 0, num);
System.arraycopy(letters, 0, result, num, 4);
System.arraycopy(l_p_Num, 0, result, num + 4, 4);
System.out.println(Arrays.toString(result));
will output:
[1, 2, 4, 5, 6, 7, 9, 8, 7, 6]
edited Nov 16 '18 at 20:59
answered Nov 16 '18 at 20:54
Karol DowbeckiKarol Dowbecki
26.8k93860
26.8k93860
1
All that'll give is 0's
– J J
Nov 16 '18 at 20:59
add a comment |
1
All that'll give is 0's
– J J
Nov 16 '18 at 20:59
1
1
All that'll give is 0's
– J J
Nov 16 '18 at 20:59
All that'll give is 0's
– J J
Nov 16 '18 at 20:59
add a comment |
So this is without the Java generics, just with for loops
int skuNum = {1,2,3};
int letters = {4,5,6};
int l_p_Num = {7,8,9};
int finalInt = new int[skuNum.length+letters.length+l_p_Num.length];
for (int i = 0; i<skuNum.length;i++) {
finalInt[i] =skuNum[i];
}
for (int i = 0; i<letters.length;i++) {
finalInt[i+skuNum.length] =letters[i];
}
for (int i = 0; i<l_p_Num.length;i++) {
finalInt[i+skuNum.length+letters.length] =l_p_Num[i];
}
for (int i : finalInt)
System.out.print(i);
Result:
123456789
If you want to have strings in it see this code:
int skuNum = {1,2,3};
String letters = {"asd","asd","aefuh"};
int l_p_Num = {7,8,9};
String finalArray = new String[skuNum.length+letters.length+l_p_Num.length];
for (int i = 0; i<skuNum.length;i++) {
finalArray[i] =String.valueOf(skuNum[i]);
}
for (int i = 0; i<letters.length;i++) {
finalArray[i+skuNum.length] =letters[i];
}
for (int i = 0; i<l_p_Num.length;i++) {
finalArray[i+skuNum.length+letters.length] = String.valueOf(l_p_Num[i]);
}
for (String st : finalArray)
System.out.print(st);
add a comment |
So this is without the Java generics, just with for loops
int skuNum = {1,2,3};
int letters = {4,5,6};
int l_p_Num = {7,8,9};
int finalInt = new int[skuNum.length+letters.length+l_p_Num.length];
for (int i = 0; i<skuNum.length;i++) {
finalInt[i] =skuNum[i];
}
for (int i = 0; i<letters.length;i++) {
finalInt[i+skuNum.length] =letters[i];
}
for (int i = 0; i<l_p_Num.length;i++) {
finalInt[i+skuNum.length+letters.length] =l_p_Num[i];
}
for (int i : finalInt)
System.out.print(i);
Result:
123456789
If you want to have strings in it see this code:
int skuNum = {1,2,3};
String letters = {"asd","asd","aefuh"};
int l_p_Num = {7,8,9};
String finalArray = new String[skuNum.length+letters.length+l_p_Num.length];
for (int i = 0; i<skuNum.length;i++) {
finalArray[i] =String.valueOf(skuNum[i]);
}
for (int i = 0; i<letters.length;i++) {
finalArray[i+skuNum.length] =letters[i];
}
for (int i = 0; i<l_p_Num.length;i++) {
finalArray[i+skuNum.length+letters.length] = String.valueOf(l_p_Num[i]);
}
for (String st : finalArray)
System.out.print(st);
add a comment |
So this is without the Java generics, just with for loops
int skuNum = {1,2,3};
int letters = {4,5,6};
int l_p_Num = {7,8,9};
int finalInt = new int[skuNum.length+letters.length+l_p_Num.length];
for (int i = 0; i<skuNum.length;i++) {
finalInt[i] =skuNum[i];
}
for (int i = 0; i<letters.length;i++) {
finalInt[i+skuNum.length] =letters[i];
}
for (int i = 0; i<l_p_Num.length;i++) {
finalInt[i+skuNum.length+letters.length] =l_p_Num[i];
}
for (int i : finalInt)
System.out.print(i);
Result:
123456789
If you want to have strings in it see this code:
int skuNum = {1,2,3};
String letters = {"asd","asd","aefuh"};
int l_p_Num = {7,8,9};
String finalArray = new String[skuNum.length+letters.length+l_p_Num.length];
for (int i = 0; i<skuNum.length;i++) {
finalArray[i] =String.valueOf(skuNum[i]);
}
for (int i = 0; i<letters.length;i++) {
finalArray[i+skuNum.length] =letters[i];
}
for (int i = 0; i<l_p_Num.length;i++) {
finalArray[i+skuNum.length+letters.length] = String.valueOf(l_p_Num[i]);
}
for (String st : finalArray)
System.out.print(st);
So this is without the Java generics, just with for loops
int skuNum = {1,2,3};
int letters = {4,5,6};
int l_p_Num = {7,8,9};
int finalInt = new int[skuNum.length+letters.length+l_p_Num.length];
for (int i = 0; i<skuNum.length;i++) {
finalInt[i] =skuNum[i];
}
for (int i = 0; i<letters.length;i++) {
finalInt[i+skuNum.length] =letters[i];
}
for (int i = 0; i<l_p_Num.length;i++) {
finalInt[i+skuNum.length+letters.length] =l_p_Num[i];
}
for (int i : finalInt)
System.out.print(i);
Result:
123456789
If you want to have strings in it see this code:
int skuNum = {1,2,3};
String letters = {"asd","asd","aefuh"};
int l_p_Num = {7,8,9};
String finalArray = new String[skuNum.length+letters.length+l_p_Num.length];
for (int i = 0; i<skuNum.length;i++) {
finalArray[i] =String.valueOf(skuNum[i]);
}
for (int i = 0; i<letters.length;i++) {
finalArray[i+skuNum.length] =letters[i];
}
for (int i = 0; i<l_p_Num.length;i++) {
finalArray[i+skuNum.length+letters.length] = String.valueOf(l_p_Num[i]);
}
for (String st : finalArray)
System.out.print(st);
edited Nov 16 '18 at 21:08
answered Nov 16 '18 at 21:00
Emanuel GrafEmanuel Graf
409827
409827
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53345164%2fhow-can-i-put-two-or-more-arrays-into-a-single-array%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How are you going to order the values in the new array? Just put all of one array's values in then the next array, then the 3rd?
– Ryan Wilson
Nov 16 '18 at 20:51
What I want is to have a new array with the three arrays values in an index. What I have will give me 00001 DVAH 4238. 00001 is in the first array, DVAH in the second, and 4238 in the third. What I now want is 00001 DVAH 4238 in a single array.
– J J
Nov 16 '18 at 20:53
3
What does that mean??
– shmosel
Nov 16 '18 at 20:53
Have a look at my answer :)
– Emanuel Graf
Nov 16 '18 at 21:10