I have a code that I am trying to use for AI, and I am getting a strange error like result, even though the program can execute.

here is what is displayed when I print out the character array after converting to a string.

[Ljava.lang.Character;@2e3fe12e

Here is what I am adding to my array

for (Point p : s1){
					if (p.x == puckX && p.y == puckY){
						orderOfSensors[numSensHit] = 'A';
						numSensHit += 1;
					}
				}

what is causing this problem?

Thanks for your help.

[Ljava.lang.Character;@2e3fe12e

That is the value returned when you call an array of character's toString() method for example when you are trying to print it.
If you want to see all the characters in the array, use the Arrays class's toString() method to format it for printing.

I am pretty sure that is what I am using when I print out with this statement

System.out.println(orderOfSensors.toString());

this is what game me that message

Yes that is what I said.
What do you want printed instead?
Did you see what I said earlier was a way to format an array for printing?

ok. I have changed it a little bit, and I have changed the result. I temoved the toString(), and now it gives me squares. Why is this?

ok. I have changed it a little bit, and I have changed the result. I temoved the toString(), and now it gives me squares. Why is this?

check here i did this to show you run it and see output:

char[] a = new char[3];
        a[0]='A';
        a[1]='B';
        a[2]='C';
        String tmp="";
        for(int i=0;i<a.length;i++)
            tmp+=a[i];
        System.out.println(tmp);//using a String gives ABC
        System.out.println(a);//no to string gives ABC
        System.out.println(a.toString());//using to string it gives unreadable
/* another example
        char[] a = new char[26];
        for(int i=0;i<26;i++) a[i]=(char)(i+65);
        System.out.println(a);//gives ABC....Z
*/

Also why not just use numSensHit++;

not that yours is wrong but its a lot more work then just ++ :) but i have no clue why it would just print squares. maybe gives uas the piece of code needed to make it work and we can see..

I have changed it a little bit, and I have changed the result

What did you change it to?
Did you try the Arrays toString() method?

I removed the toString(), and I just made it print out the actual array.

Is it working now?

it just printed a bunch of small squares, which seem to be spaces, because when I run it using cmd nothing shows up.

Can you show the code that is doing the printing?
And the code that assembles the data that is being printed.

Try using the Arrays class's toString() method to format the array for printing.
Try using the Integer class's toHexString() method to print the elements of the array.

the line I use to print is this one

System.out.println(orderOfSensors);

and the code that adds to the array is the one in my original post

Did you try any of my suggestions?
It seems I am wasting my time making them as you keep doing the same thing and having the same problem.

How could you have over 600 posts???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.