I am having a problem to understand how class inhertance works in Java.. Now I want to get information from a class to another and let's say we have class A and class B class A contains a string an int and a byte
class B contains a String and an int

but class A contains a constructor that have values set and based on a method

what I am trying to do is pass and add the values of class A and B together in one new constructor that is based on the constructor that is initlized in class A.. I know I make it sound so complicated but this is the best way I can explain it, please let me know if you need further information about it. I would really appericate the help.

It's hard to understand that description. Maybe if you posted your actual code so far that would be clearer?
Does B extend A?

it looks to me like he's trying to do something like multiple inheritance, he's trying to create a class C which inherits both the members of A and B.

this is not possible in Java, though.

Ugh no not create a third class but take the information from class A and pass them to B

I'm having a similar problem. I think I read somewhere that constructors are not inherited. But I think you can call the parent's constructor using super (I think).

commented: Yes you are right.. I used the super and it worked just fine.. Thank you. +0

there will always be a call to the parents constructor.

XHellghostx:

public class B extends A{
// ... rest of the code

this is very basic stuff. each and every textbook, bundle with coursenotes, (decent) tutorial could have told you this.
what are you working with? do you use a book? are you taking lessons? or are you just playing around a bit on your home computer?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.