How can I see the additional information about differences between two arrays, list or other collections in...
I want to compare two arrays of exactly the same size, but storing values of different types. Suppose very simple example:
Array1:
- HashMap,
- List of HashMap
Array2:
- HashMap,
- HashMap
When I use methods such us equals
or contains
, they provide me a Boolean value false
.
Is there any built-in method in Java that could print also which objects differs - their values, types and other additional information?
For example: second element of Array2 is of different type
?
java
add a comment |
I want to compare two arrays of exactly the same size, but storing values of different types. Suppose very simple example:
Array1:
- HashMap,
- List of HashMap
Array2:
- HashMap,
- HashMap
When I use methods such us equals
or contains
, they provide me a Boolean value false
.
Is there any built-in method in Java that could print also which objects differs - their values, types and other additional information?
For example: second element of Array2 is of different type
?
java
a List does not have akey
, so what are you trying to compare?
– Scary Wombat
Nov 20 '18 at 6:11
I'm trying to compare their values. Regarding my question, I'm searching for a method that will instruct me in something like that: Arrays1, element 2 and Arrays2$ element 2 are of different types or give me any hint. My example here is trivial, but suppose I have an array with 100 elements...
– matandked
Nov 20 '18 at 6:15
so have you got the values
– Scary Wombat
Nov 20 '18 at 6:17
2
No, you'll have to iterate the array yourself and extract the information you need. It's trivial enough and to dependent on what your requirements are to be in the standard library, it's really just a single loop and a method call for each index.
– daniu
Nov 20 '18 at 20:46
Could you please clarify your exact requirements? "Additional information" is a little vague to me.
– MC Emperor
Nov 20 '18 at 22:20
add a comment |
I want to compare two arrays of exactly the same size, but storing values of different types. Suppose very simple example:
Array1:
- HashMap,
- List of HashMap
Array2:
- HashMap,
- HashMap
When I use methods such us equals
or contains
, they provide me a Boolean value false
.
Is there any built-in method in Java that could print also which objects differs - their values, types and other additional information?
For example: second element of Array2 is of different type
?
java
I want to compare two arrays of exactly the same size, but storing values of different types. Suppose very simple example:
Array1:
- HashMap,
- List of HashMap
Array2:
- HashMap,
- HashMap
When I use methods such us equals
or contains
, they provide me a Boolean value false
.
Is there any built-in method in Java that could print also which objects differs - their values, types and other additional information?
For example: second element of Array2 is of different type
?
java
java
edited Nov 20 '18 at 20:36
matandked
asked Nov 20 '18 at 6:06
matandkedmatandked
56311231
56311231
a List does not have akey
, so what are you trying to compare?
– Scary Wombat
Nov 20 '18 at 6:11
I'm trying to compare their values. Regarding my question, I'm searching for a method that will instruct me in something like that: Arrays1, element 2 and Arrays2$ element 2 are of different types or give me any hint. My example here is trivial, but suppose I have an array with 100 elements...
– matandked
Nov 20 '18 at 6:15
so have you got the values
– Scary Wombat
Nov 20 '18 at 6:17
2
No, you'll have to iterate the array yourself and extract the information you need. It's trivial enough and to dependent on what your requirements are to be in the standard library, it's really just a single loop and a method call for each index.
– daniu
Nov 20 '18 at 20:46
Could you please clarify your exact requirements? "Additional information" is a little vague to me.
– MC Emperor
Nov 20 '18 at 22:20
add a comment |
a List does not have akey
, so what are you trying to compare?
– Scary Wombat
Nov 20 '18 at 6:11
I'm trying to compare their values. Regarding my question, I'm searching for a method that will instruct me in something like that: Arrays1, element 2 and Arrays2$ element 2 are of different types or give me any hint. My example here is trivial, but suppose I have an array with 100 elements...
– matandked
Nov 20 '18 at 6:15
so have you got the values
– Scary Wombat
Nov 20 '18 at 6:17
2
No, you'll have to iterate the array yourself and extract the information you need. It's trivial enough and to dependent on what your requirements are to be in the standard library, it's really just a single loop and a method call for each index.
– daniu
Nov 20 '18 at 20:46
Could you please clarify your exact requirements? "Additional information" is a little vague to me.
– MC Emperor
Nov 20 '18 at 22:20
a List does not have a
key
, so what are you trying to compare?– Scary Wombat
Nov 20 '18 at 6:11
a List does not have a
key
, so what are you trying to compare?– Scary Wombat
Nov 20 '18 at 6:11
I'm trying to compare their values. Regarding my question, I'm searching for a method that will instruct me in something like that: Arrays1, element 2 and Arrays2$ element 2 are of different types or give me any hint. My example here is trivial, but suppose I have an array with 100 elements...
– matandked
Nov 20 '18 at 6:15
I'm trying to compare their values. Regarding my question, I'm searching for a method that will instruct me in something like that: Arrays1, element 2 and Arrays2$ element 2 are of different types or give me any hint. My example here is trivial, but suppose I have an array with 100 elements...
– matandked
Nov 20 '18 at 6:15
so have you got the values
– Scary Wombat
Nov 20 '18 at 6:17
so have you got the values
– Scary Wombat
Nov 20 '18 at 6:17
2
2
No, you'll have to iterate the array yourself and extract the information you need. It's trivial enough and to dependent on what your requirements are to be in the standard library, it's really just a single loop and a method call for each index.
– daniu
Nov 20 '18 at 20:46
No, you'll have to iterate the array yourself and extract the information you need. It's trivial enough and to dependent on what your requirements are to be in the standard library, it's really just a single loop and a method call for each index.
– daniu
Nov 20 '18 at 20:46
Could you please clarify your exact requirements? "Additional information" is a little vague to me.
– MC Emperor
Nov 20 '18 at 22:20
Could you please clarify your exact requirements? "Additional information" is a little vague to me.
– MC Emperor
Nov 20 '18 at 22:20
add a comment |
0
active
oldest
votes
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%2f53387150%2fhow-can-i-see-the-additional-information-about-differences-between-two-arrays-l%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53387150%2fhow-can-i-see-the-additional-information-about-differences-between-two-arrays-l%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
a List does not have a
key
, so what are you trying to compare?– Scary Wombat
Nov 20 '18 at 6:11
I'm trying to compare their values. Regarding my question, I'm searching for a method that will instruct me in something like that: Arrays1, element 2 and Arrays2$ element 2 are of different types or give me any hint. My example here is trivial, but suppose I have an array with 100 elements...
– matandked
Nov 20 '18 at 6:15
so have you got the values
– Scary Wombat
Nov 20 '18 at 6:17
2
No, you'll have to iterate the array yourself and extract the information you need. It's trivial enough and to dependent on what your requirements are to be in the standard library, it's really just a single loop and a method call for each index.
– daniu
Nov 20 '18 at 20:46
Could you please clarify your exact requirements? "Additional information" is a little vague to me.
– MC Emperor
Nov 20 '18 at 22:20