getting an integer to return from a method - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

getting an integer to return from a method

Hi, I'm very much a newbie on java and trying to get a return value on an integer. A note: this is in the context of android dev so I can't give particular error messages that come up. I can get it to work with strings just fine, i.e.
public String getTest() {
return "Test";
(and called by)
String strTest = getTest();

This, does not work.
public int getIntTest() {
return 0;
(and called by)
int iTest = getIntTest();

is there a separate method for getting integers returned than there is for strings?
Thanks for the help.


  • erikjwagnererikjwagner Posts: 2Member
    Oy. The problem was not with how I was writing/assigning it but rather with how I was checking the value; I needed to cast the integer to a string and was not doing so.
Sign In or Register to comment.