• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

object inheritance...?

 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jhakda Velu
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
fred rosenberger
lowercase baba
Bartender
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Jhakda Velu
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Okie,i may be wrong. Please post complete error.

Jhakda
 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic