what does the output means... if we print 'intarray' we get some hash code... & same is with 'floatarray' but if we print 'chararray' we doesn't get anything what does the folowing data means?????
class Test
{
public static void main(String []aeg)
{
int []intarray = new int[5];
char []chararray = new char[5];
float []floatarray = new float[5];
System.out.println(intarray);
System.out.println(chararray);
System.out.println(floatarray);
}
}
Output starts here
after printing on the console we get following output....
F:\Mehnat\my sc\By me\ArrayList\2\2>javac Test.java
F:\Mehnat\my sc\By me\ArrayList\2\2>java Test
[I@546da8eb
[F@6b6d079a
Output ends here
Printing an array of characters tries to print the array's content as a string (one character at a time). Your new array is filled with null characters which aren't printed. Try to fill it with something and check again:
chararray[0] = 'H';
chararray[1] = 'e';
chararray[2] = 'l';
chararray[3] = 'l';
chararray[4] = 'o';
System.out.println(chararray);
Should print Hello
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With