Class that is extended from an abstract class toString method doesn't work :/

This is the main demo class

public class Ongoing{

public static void main(String[] args){

ExtendsAbstract josh = new ExtendsAbstract(5, "donkey");

System.out.println(josh.toString());

}

}

this is the class extended from the abstract class, the one who's tostring method won't work.

public class ExtendsAbstract extends Abstract{

private String t;

public ExtendsAbstract(int y, String t){

super(y);

this.t = t;

}

public String getString(){

return this.t;

}

public int getInt(){

return super.getInt();

}

public String toString(int y){

return(/*super.toString(y)+*/"The integer is "+ y) ;

}

}

This is the abstract class

public abstract class Abstract{

private int y;

public Abstract(int y){

this.y = y;

}

public int getInt(){

return y;

}

public String toString(int y){

return("The integer is :"+y);

}

}

Every time i try and access the toString...

Read More »

By: StackOverFlow - Wednesday, 7 November

Related Posts