
-----------------------------------
umaza
Wed Feb 22, 2012 10:44 pm

Return string from a method
-----------------------------------
How do I return string from a method, I tried following code bellow as a test, it compiles but it doesn't do anything


public class TriangleCatFour
{
  public static void main (String

I am just testing and before I progress, I want to be able to accomplish this.
I have an assignment and my final goal is: http://webteach.net/ics3u/methods/methodLab.html

-----------------------------------
Insectoid
Wed Feb 22, 2012 10:46 pm

RE:Return string from a method
-----------------------------------
It's not doing anything because you're not doing anything with it. Try System.out.println(triangle(4,4,4));

-----------------------------------
joshm
Thu Feb 23, 2012 10:46 am

Re: Return string from a method
-----------------------------------
Something like this
[code]public class TriangleCatFour
{
	private int s1;
	private int s2;
	private int s3;
	public static void main(String[] args)
        {
         	TriangleCatFour triangle1 = new TriangleCatFour(4,4,4);
		System.out.println(triangle1);
        }
	public TriangleCatFour(int s1, int s2, int s3)
	{
		this.s1 = s1;
		this.s2 = s2;
		this.s3 = s3;
	}
	public String toString()
	{
		if(s1 == s2 && s1 == s3)
			return "Triangle: equilateral and acute";
		else
			return "Triangle: not equilateral and acute";
	}
}[/code]
