File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes object inheritance...? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "object inheritance...?" Watch "object inheritance...?" New topic
Author

object inheritance...?

Chris Dancy
Ranch Hand

Joined: Feb 14, 2006
Posts: 136
so I have an array of public static Objects[] obj = (new Curriculum(),new referrences(),new Transcripts(),new Resume());

each of these 4 classes holds 3 arrays:

public static Objects [][] obj;
public static String [] con;
public static String [];


//The problem comes when i pass the reference of these objects i.e.:

for(int i = 0;i < obj.length;i++){
initializeObject(obj[i]);
}

//This is where the problem happens
public void initializeObject(Object i){
i.con[i] = new String("bearss");
}

//This code is always highlighted as something is wrong. It sais that i.con[i] is not a valid field or something to that degree. I have a feeling that when I pass each reference in as an object something bad is happening. Though I cant figure out why, seeing as every object is an object!!!

any ideas?

sincerely,
Chris Dancy


("Anger is not an emotion, its a symptom of fear.")
Jhakda Velu
Ranch Hand

Joined: Feb 26, 2008
Posts: 166
Hi

the first i stands for the object
the second i should be the index, but where have you declared it?
if you say in teh for loop, that i will not be available in the initializeObject method.
What do you feel?

Jhakda


If I become filthy rich, I'll sponsor research for painless dental treatment at Harvard Medical School. Thats why,I'm learning Java.I have 32 teeth, 22 are man made.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

It sais that i.con[i] is not a valid field or something to that degree
believe it or not, what is says is VERY helpful. It would help us help you if you posted EXACTLY what it says...


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jhakda Velu
Ranch Hand

Joined: Feb 26, 2008
Posts: 166
Hi
Okie,i may be wrong. Please post complete error.

Jhakda
Chris Dancy
Ranch Hand

Joined: Feb 14, 2006
Posts: 136
Its ok guys i figured it out. I simply created an abstract class and had all my four classes extend from that. That worked out beautifully. Im still puzzled as to why I had to do that considering i was just referencing an object being passed in, but its ok. Thanks anyway. and sorry for not completing the code snippet I was in a bit of a rush and posted it at the last minute.

sincerely,
Chris Dancy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: object inheritance...?