public class phone
{
String host,pages,logo,tel;
String host_show(String http_host)
  {
  this.host=http_host;
  return(this.host);
   }
  public String pages_show(String http_pages)
   { 
   this.pages=http_pages;
   return(this.pages);
   }
String show()
 {
 return(host+pages);
   }
}class phone2 extends phone
 {
  int x,y;
  int phone2(int dx,int dy)
   {
x=dx;
y=dy;
return(x+y);
out.print("<br>");
   }
 }
程序在运行后,提示  “ out.print("<br>")”出错,提示信息:
An error occurred at line: 44 in the jsp file: /1x.jsp
不知道是什么原因,小弟刚刚开始学java,请各位大哥,大姐多多指教,分不够就加!!!!!!

解决方案 »

  1.   

    你在class中没有输出流对象,如何输出呢????
      

  2.   

    还有our.println("<br>")写在return 之后本来就有问题
      

  3.   

    class phone2 extends phone{
      int x,y;
      int phone2(int dx,int dy){
         x=dx;
         y=dy;
         return(x+y);//已经return了,后面的语句走不到的
         out.print(" <br>");
       }
      

  4.   


    public class phone 

    String host,pages,logo,tel; 
    String host_show(String http_host) 
      { 
      this.host=http_host; 
      return(this.host); 
       } 
      public String pages_show(String http_pages) 
       {  
       this.pages=http_pages; 
       return(this.pages); 
       } 
    String show() 
     { 
     return(host+pages); 
       } 
    } class phone2 extends phone 
     { 
      int x,y; 
      int phone2(int dx,int dy) 
       { 
    x=dx; 
    y=dy; 
    return(x+y);   //你的程序执行到这里之后已经返回了 不会继续执行下面的语句
    out.print(" <br>"); 
       } 
     } 
      

  5.   

    你的out是什么,在哪里声明了
      

  6.   

    是掉了 System.   了吧?还有楼上几位说的问题,return后面的语句不会被执行到的。
      

  7.   

     44 in the jsp file: /1x.jsp 这是jsp文件 out是内置对象,有楼上几位说的问题,return后面的语句不会被执行到的。
      

  8.   

    个人意见主要有以下几点:
    一、构造器(也称构造方法)是不用声明返回值,所以在方法体中不用写return,所以即使后面的out.print(" <br>"); 这一行修改正确后,程序还是会报错.
    二、关于out.print(" <br>"); 这一行,估计LZ还没有想到输入输出流这方面的知识,可能就是调用System类的输出方法时犯了错误,正确写法应该为System.out.print(" <br>"); 修改结果
    class phone2 extends phone 
     { 
      int x,y; 
      phone2(int dx,int dy) 
       { 
    x=dx; 
    y=dy; 
    System.out.print(" <br>");
       } 
     } 
    建议把带show的方法的2种功能分开来写
    例如
    String host_show(String http_host) 
      { 
      this.host=http_host; 
      return(this.host); 
       } 
    最好写为
    void setHost(String http_host)
    {
     host=http_host;
    }
    String getHost()
    {
     return host;
    }
    然后再把变量host声望为私有(private)另外在方法中多次使用this,其实不正确,以上个例子而言,方法体中并没有和类体中的host同名的变量,所以根本没必要用this