I'm new to Java, and currently learning how methods work in Classes. I wrote a simple method that should return a String value, but when i concatenated it with a int value it still works.
I tried flipping the return value to start off with the int and that also worked. Does java know to convert the int value into a String value?
public class MyOwnJavaProject
{
int favoriteNumber;
....
// This method worked
public String showFavNumber()
{
return "My favorite number is " + this.favoriteNumber;
}
// This method also worked
public String showFavNumber()
{
return this.favoriteNumber + " is my favorite number";
}