toString not working on Lists with Integer data type [duplicate]
up vote
-3
down vote
favorite
This question already has an answer here:
Arrays.asList() not working as it should?
9 answers
Using Arrays.asList with int array
2 answers
How Arrays.asList(int) can return List<int>?
4 answers
What is a raw type and why shouldn't we use it?
14 answers
I am trying to print out my "numsList" but it prints out the memory address instead of the list elements. I have another list with String as my data type and it works fine. Is this an issue with Java 8? Thank you for any insight.
Here is my code:
String names = {"Rahul", "Utkarsh", "Shubham", "Neelam"};
List namesList = Arrays.asList(names);
System.out.println(namesList);
int nums = {3, 6, 2, 5, 8, 2, 11, 72, 7, 3, 19};
List numslist = Arrays.asList(nums);
System.out.println(numslist);
Another issue I just found while typing this is that if I specify the data type after List I get an error with numsList.
Here's what I mean;
String names = {"Rahul", "Utkarsh", "Shubham", "Neelam"};
List<String> namesList = Arrays.asList(names);
System.out.println(namesList);
int nums = {3, 6, 2, 5, 8, 2, 11, 72, 7, 3, 19};
List<Integer> numslist = Arrays.asList(nums);
System.out.println(numslist);
java list
marked as duplicate by Sotirios Delimanolis
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 16:05
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
show 1 more comment
up vote
-3
down vote
favorite
This question already has an answer here:
Arrays.asList() not working as it should?
9 answers
Using Arrays.asList with int array
2 answers
How Arrays.asList(int) can return List<int>?
4 answers
What is a raw type and why shouldn't we use it?
14 answers
I am trying to print out my "numsList" but it prints out the memory address instead of the list elements. I have another list with String as my data type and it works fine. Is this an issue with Java 8? Thank you for any insight.
Here is my code:
String names = {"Rahul", "Utkarsh", "Shubham", "Neelam"};
List namesList = Arrays.asList(names);
System.out.println(namesList);
int nums = {3, 6, 2, 5, 8, 2, 11, 72, 7, 3, 19};
List numslist = Arrays.asList(nums);
System.out.println(numslist);
Another issue I just found while typing this is that if I specify the data type after List I get an error with numsList.
Here's what I mean;
String names = {"Rahul", "Utkarsh", "Shubham", "Neelam"};
List<String> namesList = Arrays.asList(names);
System.out.println(namesList);
int nums = {3, 6, 2, 5, 8, 2, 11, 72, 7, 3, 19};
List<Integer> numslist = Arrays.asList(nums);
System.out.println(numslist);
java list
marked as duplicate by Sotirios Delimanolis
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 16:05
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
nameList is a HasCode code andthat's exactly was it will be printed.
– Tsakiroglou Fotis
Nov 20 at 16:06
You can't print a List.You can print an element of a List (or Array).You can also iterate an list (or array) , does those two make sense?
– Tsakiroglou Fotis
Nov 20 at 16:08
Please avoid asking multiple distinct questions at once. You can check out this post on how to print a list.
– Ivar
Nov 20 at 16:10
@TsakiroglouFotis namesList’s output was the same as the names Array. My problem is with numsList. The hash code for numsList appears while namesList gets printed out.
– Jamil Ahmed
Nov 20 at 18:37
@TsakiroglouFotis yes you can print a list. The list class comes with a toString method. toString worked on my List that has Strings but not nums.
– Jamil Ahmed
Nov 20 at 18:38
|
show 1 more comment
up vote
-3
down vote
favorite
up vote
-3
down vote
favorite
This question already has an answer here:
Arrays.asList() not working as it should?
9 answers
Using Arrays.asList with int array
2 answers
How Arrays.asList(int) can return List<int>?
4 answers
What is a raw type and why shouldn't we use it?
14 answers
I am trying to print out my "numsList" but it prints out the memory address instead of the list elements. I have another list with String as my data type and it works fine. Is this an issue with Java 8? Thank you for any insight.
Here is my code:
String names = {"Rahul", "Utkarsh", "Shubham", "Neelam"};
List namesList = Arrays.asList(names);
System.out.println(namesList);
int nums = {3, 6, 2, 5, 8, 2, 11, 72, 7, 3, 19};
List numslist = Arrays.asList(nums);
System.out.println(numslist);
Another issue I just found while typing this is that if I specify the data type after List I get an error with numsList.
Here's what I mean;
String names = {"Rahul", "Utkarsh", "Shubham", "Neelam"};
List<String> namesList = Arrays.asList(names);
System.out.println(namesList);
int nums = {3, 6, 2, 5, 8, 2, 11, 72, 7, 3, 19};
List<Integer> numslist = Arrays.asList(nums);
System.out.println(numslist);
java list
This question already has an answer here:
Arrays.asList() not working as it should?
9 answers
Using Arrays.asList with int array
2 answers
How Arrays.asList(int) can return List<int>?
4 answers
What is a raw type and why shouldn't we use it?
14 answers
I am trying to print out my "numsList" but it prints out the memory address instead of the list elements. I have another list with String as my data type and it works fine. Is this an issue with Java 8? Thank you for any insight.
Here is my code:
String names = {"Rahul", "Utkarsh", "Shubham", "Neelam"};
List namesList = Arrays.asList(names);
System.out.println(namesList);
int nums = {3, 6, 2, 5, 8, 2, 11, 72, 7, 3, 19};
List numslist = Arrays.asList(nums);
System.out.println(numslist);
Another issue I just found while typing this is that if I specify the data type after List I get an error with numsList.
Here's what I mean;
String names = {"Rahul", "Utkarsh", "Shubham", "Neelam"};
List<String> namesList = Arrays.asList(names);
System.out.println(namesList);
int nums = {3, 6, 2, 5, 8, 2, 11, 72, 7, 3, 19};
List<Integer> numslist = Arrays.asList(nums);
System.out.println(numslist);
This question already has an answer here:
Arrays.asList() not working as it should?
9 answers
Using Arrays.asList with int array
2 answers
How Arrays.asList(int) can return List<int>?
4 answers
What is a raw type and why shouldn't we use it?
14 answers
java list
java list
asked Nov 20 at 16:04
Jamil Ahmed
1
1
marked as duplicate by Sotirios Delimanolis
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 16:05
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Sotirios Delimanolis
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 16:05
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
nameList is a HasCode code andthat's exactly was it will be printed.
– Tsakiroglou Fotis
Nov 20 at 16:06
You can't print a List.You can print an element of a List (or Array).You can also iterate an list (or array) , does those two make sense?
– Tsakiroglou Fotis
Nov 20 at 16:08
Please avoid asking multiple distinct questions at once. You can check out this post on how to print a list.
– Ivar
Nov 20 at 16:10
@TsakiroglouFotis namesList’s output was the same as the names Array. My problem is with numsList. The hash code for numsList appears while namesList gets printed out.
– Jamil Ahmed
Nov 20 at 18:37
@TsakiroglouFotis yes you can print a list. The list class comes with a toString method. toString worked on my List that has Strings but not nums.
– Jamil Ahmed
Nov 20 at 18:38
|
show 1 more comment
nameList is a HasCode code andthat's exactly was it will be printed.
– Tsakiroglou Fotis
Nov 20 at 16:06
You can't print a List.You can print an element of a List (or Array).You can also iterate an list (or array) , does those two make sense?
– Tsakiroglou Fotis
Nov 20 at 16:08
Please avoid asking multiple distinct questions at once. You can check out this post on how to print a list.
– Ivar
Nov 20 at 16:10
@TsakiroglouFotis namesList’s output was the same as the names Array. My problem is with numsList. The hash code for numsList appears while namesList gets printed out.
– Jamil Ahmed
Nov 20 at 18:37
@TsakiroglouFotis yes you can print a list. The list class comes with a toString method. toString worked on my List that has Strings but not nums.
– Jamil Ahmed
Nov 20 at 18:38
nameList is a HasCode code andthat's exactly was it will be printed.
– Tsakiroglou Fotis
Nov 20 at 16:06
nameList is a HasCode code andthat's exactly was it will be printed.
– Tsakiroglou Fotis
Nov 20 at 16:06
You can't print a List.You can print an element of a List (or Array).You can also iterate an list (or array) , does those two make sense?
– Tsakiroglou Fotis
Nov 20 at 16:08
You can't print a List.You can print an element of a List (or Array).You can also iterate an list (or array) , does those two make sense?
– Tsakiroglou Fotis
Nov 20 at 16:08
Please avoid asking multiple distinct questions at once. You can check out this post on how to print a list.
– Ivar
Nov 20 at 16:10
Please avoid asking multiple distinct questions at once. You can check out this post on how to print a list.
– Ivar
Nov 20 at 16:10
@TsakiroglouFotis namesList’s output was the same as the names Array. My problem is with numsList. The hash code for numsList appears while namesList gets printed out.
– Jamil Ahmed
Nov 20 at 18:37
@TsakiroglouFotis namesList’s output was the same as the names Array. My problem is with numsList. The hash code for numsList appears while namesList gets printed out.
– Jamil Ahmed
Nov 20 at 18:37
@TsakiroglouFotis yes you can print a list. The list class comes with a toString method. toString worked on my List that has Strings but not nums.
– Jamil Ahmed
Nov 20 at 18:38
@TsakiroglouFotis yes you can print a list. The list class comes with a toString method. toString worked on my List that has Strings but not nums.
– Jamil Ahmed
Nov 20 at 18:38
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
nameList is a HasCode code andthat's exactly was it will be printed.
– Tsakiroglou Fotis
Nov 20 at 16:06
You can't print a List.You can print an element of a List (or Array).You can also iterate an list (or array) , does those two make sense?
– Tsakiroglou Fotis
Nov 20 at 16:08
Please avoid asking multiple distinct questions at once. You can check out this post on how to print a list.
– Ivar
Nov 20 at 16:10
@TsakiroglouFotis namesList’s output was the same as the names Array. My problem is with numsList. The hash code for numsList appears while namesList gets printed out.
– Jamil Ahmed
Nov 20 at 18:37
@TsakiroglouFotis yes you can print a list. The list class comes with a toString method. toString worked on my List that has Strings but not nums.
– Jamil Ahmed
Nov 20 at 18:38