• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

object inheritance...?

 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic