• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

int to ""

 
Melinda Wilson
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a method that returns an integer. I am testing this integer value for null, if null I return 0 (zero). I do not want 0 to be displayed instead a blank/empty string. How do I do this?
<%= monthlyPaymentPlan.getInstallmentCount() > 0 ?monthlyPaymentPlan.getInstallmentCount() : 0 %>
Thank you.
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Melinda
If I understand you correctly then you can't return an empty string from a method that is declared to return an int. You could just test it after it is returned and then display the appropriate repsonse or change the method to return a string and if you have an int value then use toString to change it to a string value to be returned.
If I didn't understand your question let me know

------------------
Dave
Sun Certified Programmer for the Java� 2 Platform
 
Melinda Wilson
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The rest of my post didn't get posted here is the method:
monthlyPaymentPlan.getInstallmentCount() > 0 ? monthlyPaymentPlan.getInstallmentCount() : 0
Lets see if the toString will do it.
Thanks.
 
Fei Ng
Ranch Hand
Posts: 1245
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
toString will turn it into a string "0" not empty space.
Can do a if statement to test it and just System.out.print("");
instead?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic