Wednesday, 20 July 2016

java - Why won't my array print out correctly?

I am trying to write a simple program using the code below to make a single dimensional array that you can then call a value from using the index numbers. I am using and as my compiler. Whenever I try to debug or run the program, the full array prints out as this: [I@1fa8d3b.



class Array    
{
public static void main(String[] args)
{

int[] MyArray = new int[] {15, 45, 34, 78, 65, 47, 90, 32, 54, 10};
System.out.println("The full array is:");
System.out.println(MyArray);
System.out.println("The 4th entry in the data is: " + MyArray[3]);
}
}


The correct data entry prints out when it is called though. I have tried to look for answers online as to what I should do, but I could not find anything that actually works. I am just starting to learn Java so there could be a very simple answer to this that I am just overlooking. If anyone has any ideas, I would be greatly appreciative.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...