Few questions on over riding.

I am interiting a method openRead from another class, the method is to be overridden so that the scanner class uses the provided delimiter pattern, which is referenced. I need to make use of the scanner method.

method from another class

public boolean openRead() throws FileNotFoundException
   sc = new Scanner(new File(fileName));
    if (fileName != null)
         return true;
        return false;


protected final String DELIMITERS = "[\\s[^'a-zA-Z]]";

I'm at a loss to how i over ride this using the constant delimiter.

If i have a method which is to override another method but extend it, do i use for example update.super() and then write the code i want to extend it with?

Edited by bangor_boy: n/a

7 Years
Discussion Span
Last Post by pbl

You can just overload a method
You will have first to extends the class then you can overload the method

class MyClass extends theClassThatContainsOpenRead {

   // now you can overload
   public boolean openRead() throws.... {
     // your code here
     // if filename and sc are private you will have to use the getter/setter for
     // them or you just can't overload
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.