一个检测能否构成三角形的程序,但编译时总提示未结束的字符串字面值
import java.io.*;
public class TriangleTest 
{
  public static void main(String[] args)throws Exception
  {
   try
   {
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   String str;
   System.out.println("输入第一条边");
   str=br.readLine();
   int side1=Integer.parseInt(str);
   System.out.println("输入第二条边");
   str=br.readLine();
   int side2=Integer.parseInt(str);
   System.out.println("输入第三条边");
   str=br.readLine();
   int side3=Integer.parseInt(str);
      if(isTriangle(side1,side2,side3))
      System.out.println("can composing triangle");
    }
    catch(TriangleException e)
    {
     e.toString();
    }
  }
  static boolean isTriangle(int side1,int side2,int side3)
   {
   if(side1+side2>side3
   &&side1+side3>side2
   &&side2+side3>side1)
   return true;
   else
  throw new TriangleException();
   }
}
class TriangleException extends Exception
{
TriangleException()
{
super("triangle side error!");
}
public String toString()
{
return "triangle side error:the margin of radom tow sides must 
be smaller than the third one and sum of random tow sides must be bigger than the third one and 
the sides can not be negative";
}
}
提示如下:
TriangleTest.java:45:未结束的字符串字面值
                    return"triangle side erroe:the margin of radom tow sides must
TriangleTest.java:47:未结束的字符串字面值
                      the sides can not be negative";
这两句是什么意思啊

解决方案 »

  1.   


    import java.io.*;public class TriangleTest {
    public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str;
    System.out.println("输入第一条边");
    str = br.readLine();
    int side1 = Integer.parseInt(str);
    System.out.println("输入第二条边");
    str = br.readLine();
    int side2 = Integer.parseInt(str);
    System.out.println("输入第三条边");
    str = br.readLine();
    int side3 = Integer.parseInt(str);
    if (isTriangle(side1, side2, side3))
    System.out.println("can composing triangle");
    } static boolean isTriangle(int side1, int side2, int side3) {
    if (side1 + side2 > side3 && side1 + side3 > side2
    && side2 + side3 > side1)
    return true;
    else
    return false;
    }
    }class TriangleException extends Exception {
    TriangleException() {
    super("triangle side error!");
    } public String toString() {
    return "111";
    }
    }
      

  2.   

    return "triangle side error:the margin of radom tow sides must
    be smaller than the third one and sum of random tow sides must be bigger than the third one and
    the sides can not be negative"; 
    改成
    return "triangle side error:the margin of radom tow sides must"+
    "be smaller than the third one and sum of random tow sides must be bigger than the third one and"+
    "the sides can not be negative"; 
    字符串中间是不允许换行的,换的话必须用+连接起来