wood burning stoves
The moose likes Beginning Java and the fly likes Inheritance of a Variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inheritance of a Variable" Watch "Inheritance of a Variable" New topic

Inheritance of a Variable

Ravi Pydi

Joined: Sep 01, 2002
Posts: 25
Iam an amateur to JAVA Programming. Iam working on a task where i should be reading a TEXT file as input and do some validations on the data.
I have created a class(Validation.java). I have used DataInputStream to read the data. And the data is stored onto a String variable (say allData) using the readLine() method.
I have declared the varible as an instance variable in the super class.
public allData;
Then i have instantiated the class and the input stream.
Validation val = new Validation();
val.allData = instr.readLine();
//Note:Assuming the input stream is declaread and instantiated.
Iam getting the output that was desired. Now i have done some validations on the data and everything is working fine.
Now i want to use the same variable "allData" in another class.
I have created a subclass and EXTENDED the super class where "allData" variable exists. I have put both the classes into the same PACKAGE.
When i instantiated the subclass (ValidationSub) and printed the "allData" value iam getting null as output. But i want to get the output similar to the output i got in my superclass.
Note: i havent declared any variable in my subclass since it is already declared in the superclass.
How do i get the data assigned to my variable in superclass into my subclass?
I will be glad if anybody could suggest on this.
Thanking you,
Ravi Pydi
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Hi friend here's a sample test case:

How are you doing it?
I agree. Here's the link: http://aspose.com/file-tools
subject: Inheritance of a Variable
It's not a secret anymore!