本帖最后由 石好强 于 2012-4-13 06:08 编辑
- import java.io.*;
- class MyLineNumberReader extends BufferedReader
- {
- private FileReader fr;
- MyLineNumberReader(FileReader fr)
- {
- super(in){}
- this.fr = fr;
- }
- public void MysetLineNumber(int num)
- {
- int lnum = num;
- int ch = 0;
- while((ch=fr.read())!=-1)
- {
- if((char)ch=='\r')
- lnum++;
- }
- }
- public int MygetLineNumber()
- {
- int ch = 0;
- int lnum = 1;
- while((ch=fr.read())!=-1)
- {
- if((char)ch=='\r')
- lnum++;
- }
- }
- public void close() throws IOException
- {
- fr.close();
- }
- public int read(char[] cbuf,int off,int len) throws IOException
- {
- fr.read(cbuf,off,len);
- }
- }
- class MyLineNumberReaderDemo
- {
- public static void main(String[] args)
- {
- FileReader fr = new FileReader("PersonDemo.java");
- MyLineNumberReader mlnr = new MyLineNumberReader(fr);
- String line = null;
- while((line = mlnr.readLine())!=null)
- {
- System.out.println(mlnr.MygetLineNumber()+":"+line);
- }
- }
- }
复制代码 报错:
D:\java1203\day19>javac MyLineNumberReaderDemo.java
MyLineNumberReaderDemo.java:12: 需要 ';'
super(in){}
^
1 错误
请问这个父类的构造函数应该怎么写啊?
改成super(in);
仍然有报错,有高人帮忙改下代码吗,看看这个代码到底问题出在哪了。 |