Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!