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.


  • 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.

Howdy, Stranger!

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


In this Discussion