Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About default values in array

 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the code below:
float ff[] = new float[2];
System.out.println("The value of float is " + ff[0]);
System.out.println("The value of float is " + ff[1]);

It displays the output as:
The value of float is 0.0
The value of float is 0.0

Well, i was wondering whether 0.0f should be displayed rather than 0.0??
 
Lakshmi Keshav
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
0.0f is for assigning literals to float variables. Display does not show any appended f.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic