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 method from the extended class it just prints out what i think is a memory address. I even didn't mess with the abstract class and it still did that, does anyone know why? Also another question about abstract classes, what advantages do they bring, is it just memory? Because you can't access private members from it so isn't it the same as a normal class, just more restrictions?