Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Java int[] Array [I@24a1a602](Eclipse error when using int array)
Java int[] Array [I@24a1a602] [message #1125692] Fri, 04 October 2013 19:58 Go to next message
Preston Deason is currently offline Preston DeasonFriend
Messages: 3
Registered: October 2013
Junior Member
Hello all, I'm having an immense amount of trouble creating integer arrays.
I try to declare them like this:

int[] intArray = new int[5]


And when I try to print the output to the console, I receive this:

[I@24a1a602]


I'm not sure what this means, if I'm doing something wrong, or what's happening.
I'm very sorry if this is in the wrong section, or if this has been answered before. I tried doing some searches but nothing seemed to have come up.

Thank you in advance for any help you can provide!
Re: Java int[] Array [I@24a1a602] [message #1126154 is a reply to message #1125692] Sat, 05 October 2013 07:54 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Preston,

Comments below.

On 05/10/2013 2:17 AM, Preston Deason wrote:
> Hello all, I'm having an immense amount of trouble creating integer
> arrays.
> I try to declare them like this:
>
> int[] intArray = new int
>
> And when I try to print the output to the console, I receive this:
>
> [I@24a1a602]
Yes, that's expected. The toString implementation of any array is not
all that pretty. It follows the basic default pattern of
<class-name>@<system-hash-code>. In this case, because it's an array
class, it starts with [, and because it's "int" the special short name
for that is I so you see "[I" as the class name.
>
> I'm not sure what this means, if I'm doing something wrong, or what's
> happening.
Nothing is wrong.
> I'm very sorry if this is in the wrong section, or if this has been
> answered before. I tried doing some searches but nothing seemed to
> have come up.
> Thank you in advance for any help you can provide!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Java int[] Array [I@24a1a602] [message #1126478 is a reply to message #1126154] Sat, 05 October 2013 16:09 Go to previous messageGo to next message
Eclipse UserFriend
Use Arrays.toString(intArray) to get the behavior you probably want.


On 10/5/2013 3:54 AM, Ed Merks wrote:
> Preston,
>
> Comments below.
>
> On 05/10/2013 2:17 AM, Preston Deason wrote:
>> Hello all, I'm having an immense amount of trouble creating integer arrays.
>> I try to declare them like this:
>>
>> int[] intArray = new int
>>
>> And when I try to print the output to the console, I receive this:
>>
>> [I@24a1a602]
> Yes, that's expected. The toString implementation of any array is not all that pretty. It follows the basic default pattern of <class-name>@<system-hash-code>. In this case, because it's an array
> class, it starts with [, and because it's "int" the special short name for that is I so you see "[I" as the class name.
>>
>> I'm not sure what this means, if I'm doing something wrong, or what's happening.
> Nothing is wrong.
>> I'm very sorry if this is in the wrong section, or if this has been answered before. I tried doing some searches but nothing seemed to have come up.
>> Thank you in advance for any help you can provide!
>
Re: Java int[] Array [I@24a1a602] [message #1126485 is a reply to message #1126154] Sat, 05 October 2013 16:16 Go to previous messageGo to next message
Preston Deason is currently offline Preston DeasonFriend
Messages: 3
Registered: October 2013
Junior Member
Fantastic, thank you very much for the explanation.

I guess my next question is then, if I want to display the contents of an integer array, how would I do that?
I apologize if I'm a bit ignorant here, I'm trying to gain some experience.
Re: Java int[] Array [I@24a1a602] [message #1126516 is a reply to message #1126485] Sat, 05 October 2013 17:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Preston,

You saw the other answer to your question from Bill?


On 05/10/2013 6:16 PM, Preston Deason wrote:
> Fantastic, thank you very much for the explanation.
>
> I guess my next question is then, if I want to display the contents of
> an integer array, how would I do that?
> I apologize if I'm a bit ignorant here, I'm trying to gain some
> experience.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Java int[] Array [I@24a1a602] [message #1126551 is a reply to message #1126516] Sat, 05 October 2013 18:01 Go to previous message
Preston Deason is currently offline Preston DeasonFriend
Messages: 3
Registered: October 2013
Junior Member
I must have posted right after Bill and completely missed it!
Sorry about that, and thank you so much for all your help!
Previous Topic:Hamcrest conflict with JUnit runner - signed/unsigned jars
Next Topic:JDT auto completion error
Goto Forum:
  


Current Time: Thu Apr 25 04:31:23 GMT 2024

Powered by FUDForum. Page generated in 0.03204 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top