get some object of one class and use in another class
I want to use some object of one class and use in other class,but i can not
for example :
class 1:
public class Value {
private double radious;
private double lenght;
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
}
question : how can I use just radious of class 1 in class 2???
class 2:
public class calculateArea
{
private Value value;
public double area()
{
return 3.14*radious*radious;
}
}
java
add a comment |
I want to use some object of one class and use in other class,but i can not
for example :
class 1:
public class Value {
private double radious;
private double lenght;
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
}
question : how can I use just radious of class 1 in class 2???
class 2:
public class calculateArea
{
private Value value;
public double area()
{
return 3.14*radious*radious;
}
}
java
add getters, but you'll also need an instance of your first class there
– Stultuske
Nov 22 '18 at 12:30
add a comment |
I want to use some object of one class and use in other class,but i can not
for example :
class 1:
public class Value {
private double radious;
private double lenght;
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
}
question : how can I use just radious of class 1 in class 2???
class 2:
public class calculateArea
{
private Value value;
public double area()
{
return 3.14*radious*radious;
}
}
java
I want to use some object of one class and use in other class,but i can not
for example :
class 1:
public class Value {
private double radious;
private double lenght;
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
}
question : how can I use just radious of class 1 in class 2???
class 2:
public class calculateArea
{
private Value value;
public double area()
{
return 3.14*radious*radious;
}
}
java
java
edited Nov 22 '18 at 12:41
MTCoster
3,13621940
3,13621940
asked Nov 22 '18 at 12:28
AshkanAshkan
165
165
add getters, but you'll also need an instance of your first class there
– Stultuske
Nov 22 '18 at 12:30
add a comment |
add getters, but you'll also need an instance of your first class there
– Stultuske
Nov 22 '18 at 12:30
add getters, but you'll also need an instance of your first class there
– Stultuske
Nov 22 '18 at 12:30
add getters, but you'll also need an instance of your first class there
– Stultuske
Nov 22 '18 at 12:30
add a comment |
5 Answers
5
active
oldest
votes
Create getters for both the values and access them in your second class.
Something like
public double getRadious() {
return this.radious;
}
public double getLenght() {
return this.lenght;
}
without having an instance, having those getters won't be enough
– Stultuske
Nov 22 '18 at 12:33
add a comment |
When working on OOP, ask yourself what code goes where and how many classes you have to make?
For your scenario, you can use aggregation or composition which is to declare the object of one class in another and then you can call the methods of the declared object using dot notation with getter setter methods. So it will go like this.
public class Value
{
private double radious;
private double lenght;
public void setRadious(double radious)
{
this.radious = radious;
}
public double getRadious() {
return this.radious;
}
public double getLenght() {
return this.lenght;
}
public void setLenght(double lenght)
{
this.lenght = lenght;
}
}
Class # 2
public class calculateArea
{
private Value value = new Value();
public calculateArea(double rad) {
value.setRadius(rad);
}
public double area()
{
return 3.14*value.getRadious()*value.getRadious();
}
}
Also, you need to set the value of radius before using it.
how would they set it? your code doesn't provide the possibility of doing so
– Stultuske
Nov 22 '18 at 13:08
edited the snippet to set the value of radius.
– Ahsan
Nov 22 '18 at 13:35
add a comment |
Make a getter Method for radious:
public double getRadious(){
return radious;
}
In the "Main Class":
Value v = new Value();
v.setRadious(2.5);/*Set the Radious value*/
public double area()
{
return 3.14*v.getRadious()*v.getRadious();
}
still serious errors (both syntactic as logical) in this code
– Stultuske
Nov 22 '18 at 12:35
add a comment |
Add getters to class Value.
public class Value {
public double radious;
public double lenght;
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
public double getLenght() {
return this.lenght;
}
public double getRadious() {
return this.radious;
}
}
Make an instance of class 1
public class calculateArea{
public Value;
calculateArea(){
value = new Value();
}
public double area(){
value.setRadious(2.34);//or set ACCORDINGLY
return 3.14 * value.radious * value.radious;
}
}
you can't call value.setRadious like that. this is (at best) an incomplete answer
– Stultuske
Nov 22 '18 at 13:07
@Stultuske so tell the reason why you can't call value.setRadious() like that.
– Isuru Nuwanthilaka
Nov 22 '18 at 13:23
because it's not in a method or block.
– Stultuske
Nov 22 '18 at 13:31
@Stultuske editted.Thanks.
– Isuru Nuwanthilaka
Nov 22 '18 at 15:09
add a comment |
Declare getters and setters for Value-class:
public class Value {
private double radious;
private double lenght;
public Value(double radious, double length) {
this.radious = radious;
this.length = length;
}
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
public double getRadious() {
return this.radious;
}
public double getLength() {
return this.length;
}
}
Instantiate the object with some variables:
Value value = new Value(2.0,3.0);
Add Constructor to CalculateArea class:
public class calculateArea {
private Value value;
public calculateArea(Value value) {
this.value = value;
}
public double area()
{
return 3.14*value.getRadious()*value.getRadious();
}
}
Instantiate:
calculateArea cArea= new calculateArea(value);
And print result to console in main()
method:
System.out.println(cArea.area());
you forgot to mention why the code you posted won't compile. this is not a good answer, the errors are repeated in your answer
– Stultuske
Nov 22 '18 at 13:07
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431047%2fget-some-object-of-one-class-and-use-in-another-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Create getters for both the values and access them in your second class.
Something like
public double getRadious() {
return this.radious;
}
public double getLenght() {
return this.lenght;
}
without having an instance, having those getters won't be enough
– Stultuske
Nov 22 '18 at 12:33
add a comment |
Create getters for both the values and access them in your second class.
Something like
public double getRadious() {
return this.radious;
}
public double getLenght() {
return this.lenght;
}
without having an instance, having those getters won't be enough
– Stultuske
Nov 22 '18 at 12:33
add a comment |
Create getters for both the values and access them in your second class.
Something like
public double getRadious() {
return this.radious;
}
public double getLenght() {
return this.lenght;
}
Create getters for both the values and access them in your second class.
Something like
public double getRadious() {
return this.radious;
}
public double getLenght() {
return this.lenght;
}
answered Nov 22 '18 at 12:32
CS_noobCS_noob
4491311
4491311
without having an instance, having those getters won't be enough
– Stultuske
Nov 22 '18 at 12:33
add a comment |
without having an instance, having those getters won't be enough
– Stultuske
Nov 22 '18 at 12:33
without having an instance, having those getters won't be enough
– Stultuske
Nov 22 '18 at 12:33
without having an instance, having those getters won't be enough
– Stultuske
Nov 22 '18 at 12:33
add a comment |
When working on OOP, ask yourself what code goes where and how many classes you have to make?
For your scenario, you can use aggregation or composition which is to declare the object of one class in another and then you can call the methods of the declared object using dot notation with getter setter methods. So it will go like this.
public class Value
{
private double radious;
private double lenght;
public void setRadious(double radious)
{
this.radious = radious;
}
public double getRadious() {
return this.radious;
}
public double getLenght() {
return this.lenght;
}
public void setLenght(double lenght)
{
this.lenght = lenght;
}
}
Class # 2
public class calculateArea
{
private Value value = new Value();
public calculateArea(double rad) {
value.setRadius(rad);
}
public double area()
{
return 3.14*value.getRadious()*value.getRadious();
}
}
Also, you need to set the value of radius before using it.
how would they set it? your code doesn't provide the possibility of doing so
– Stultuske
Nov 22 '18 at 13:08
edited the snippet to set the value of radius.
– Ahsan
Nov 22 '18 at 13:35
add a comment |
When working on OOP, ask yourself what code goes where and how many classes you have to make?
For your scenario, you can use aggregation or composition which is to declare the object of one class in another and then you can call the methods of the declared object using dot notation with getter setter methods. So it will go like this.
public class Value
{
private double radious;
private double lenght;
public void setRadious(double radious)
{
this.radious = radious;
}
public double getRadious() {
return this.radious;
}
public double getLenght() {
return this.lenght;
}
public void setLenght(double lenght)
{
this.lenght = lenght;
}
}
Class # 2
public class calculateArea
{
private Value value = new Value();
public calculateArea(double rad) {
value.setRadius(rad);
}
public double area()
{
return 3.14*value.getRadious()*value.getRadious();
}
}
Also, you need to set the value of radius before using it.
how would they set it? your code doesn't provide the possibility of doing so
– Stultuske
Nov 22 '18 at 13:08
edited the snippet to set the value of radius.
– Ahsan
Nov 22 '18 at 13:35
add a comment |
When working on OOP, ask yourself what code goes where and how many classes you have to make?
For your scenario, you can use aggregation or composition which is to declare the object of one class in another and then you can call the methods of the declared object using dot notation with getter setter methods. So it will go like this.
public class Value
{
private double radious;
private double lenght;
public void setRadious(double radious)
{
this.radious = radious;
}
public double getRadious() {
return this.radious;
}
public double getLenght() {
return this.lenght;
}
public void setLenght(double lenght)
{
this.lenght = lenght;
}
}
Class # 2
public class calculateArea
{
private Value value = new Value();
public calculateArea(double rad) {
value.setRadius(rad);
}
public double area()
{
return 3.14*value.getRadious()*value.getRadious();
}
}
Also, you need to set the value of radius before using it.
When working on OOP, ask yourself what code goes where and how many classes you have to make?
For your scenario, you can use aggregation or composition which is to declare the object of one class in another and then you can call the methods of the declared object using dot notation with getter setter methods. So it will go like this.
public class Value
{
private double radious;
private double lenght;
public void setRadious(double radious)
{
this.radious = radious;
}
public double getRadious() {
return this.radious;
}
public double getLenght() {
return this.lenght;
}
public void setLenght(double lenght)
{
this.lenght = lenght;
}
}
Class # 2
public class calculateArea
{
private Value value = new Value();
public calculateArea(double rad) {
value.setRadius(rad);
}
public double area()
{
return 3.14*value.getRadious()*value.getRadious();
}
}
Also, you need to set the value of radius before using it.
edited Nov 22 '18 at 13:35
answered Nov 22 '18 at 12:43
AhsanAhsan
265214
265214
how would they set it? your code doesn't provide the possibility of doing so
– Stultuske
Nov 22 '18 at 13:08
edited the snippet to set the value of radius.
– Ahsan
Nov 22 '18 at 13:35
add a comment |
how would they set it? your code doesn't provide the possibility of doing so
– Stultuske
Nov 22 '18 at 13:08
edited the snippet to set the value of radius.
– Ahsan
Nov 22 '18 at 13:35
how would they set it? your code doesn't provide the possibility of doing so
– Stultuske
Nov 22 '18 at 13:08
how would they set it? your code doesn't provide the possibility of doing so
– Stultuske
Nov 22 '18 at 13:08
edited the snippet to set the value of radius.
– Ahsan
Nov 22 '18 at 13:35
edited the snippet to set the value of radius.
– Ahsan
Nov 22 '18 at 13:35
add a comment |
Make a getter Method for radious:
public double getRadious(){
return radious;
}
In the "Main Class":
Value v = new Value();
v.setRadious(2.5);/*Set the Radious value*/
public double area()
{
return 3.14*v.getRadious()*v.getRadious();
}
still serious errors (both syntactic as logical) in this code
– Stultuske
Nov 22 '18 at 12:35
add a comment |
Make a getter Method for radious:
public double getRadious(){
return radious;
}
In the "Main Class":
Value v = new Value();
v.setRadious(2.5);/*Set the Radious value*/
public double area()
{
return 3.14*v.getRadious()*v.getRadious();
}
still serious errors (both syntactic as logical) in this code
– Stultuske
Nov 22 '18 at 12:35
add a comment |
Make a getter Method for radious:
public double getRadious(){
return radious;
}
In the "Main Class":
Value v = new Value();
v.setRadious(2.5);/*Set the Radious value*/
public double area()
{
return 3.14*v.getRadious()*v.getRadious();
}
Make a getter Method for radious:
public double getRadious(){
return radious;
}
In the "Main Class":
Value v = new Value();
v.setRadious(2.5);/*Set the Radious value*/
public double area()
{
return 3.14*v.getRadious()*v.getRadious();
}
edited Nov 22 '18 at 12:40
answered Nov 22 '18 at 12:33
SilvanSilvan
609
609
still serious errors (both syntactic as logical) in this code
– Stultuske
Nov 22 '18 at 12:35
add a comment |
still serious errors (both syntactic as logical) in this code
– Stultuske
Nov 22 '18 at 12:35
still serious errors (both syntactic as logical) in this code
– Stultuske
Nov 22 '18 at 12:35
still serious errors (both syntactic as logical) in this code
– Stultuske
Nov 22 '18 at 12:35
add a comment |
Add getters to class Value.
public class Value {
public double radious;
public double lenght;
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
public double getLenght() {
return this.lenght;
}
public double getRadious() {
return this.radious;
}
}
Make an instance of class 1
public class calculateArea{
public Value;
calculateArea(){
value = new Value();
}
public double area(){
value.setRadious(2.34);//or set ACCORDINGLY
return 3.14 * value.radious * value.radious;
}
}
you can't call value.setRadious like that. this is (at best) an incomplete answer
– Stultuske
Nov 22 '18 at 13:07
@Stultuske so tell the reason why you can't call value.setRadious() like that.
– Isuru Nuwanthilaka
Nov 22 '18 at 13:23
because it's not in a method or block.
– Stultuske
Nov 22 '18 at 13:31
@Stultuske editted.Thanks.
– Isuru Nuwanthilaka
Nov 22 '18 at 15:09
add a comment |
Add getters to class Value.
public class Value {
public double radious;
public double lenght;
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
public double getLenght() {
return this.lenght;
}
public double getRadious() {
return this.radious;
}
}
Make an instance of class 1
public class calculateArea{
public Value;
calculateArea(){
value = new Value();
}
public double area(){
value.setRadious(2.34);//or set ACCORDINGLY
return 3.14 * value.radious * value.radious;
}
}
you can't call value.setRadious like that. this is (at best) an incomplete answer
– Stultuske
Nov 22 '18 at 13:07
@Stultuske so tell the reason why you can't call value.setRadious() like that.
– Isuru Nuwanthilaka
Nov 22 '18 at 13:23
because it's not in a method or block.
– Stultuske
Nov 22 '18 at 13:31
@Stultuske editted.Thanks.
– Isuru Nuwanthilaka
Nov 22 '18 at 15:09
add a comment |
Add getters to class Value.
public class Value {
public double radious;
public double lenght;
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
public double getLenght() {
return this.lenght;
}
public double getRadious() {
return this.radious;
}
}
Make an instance of class 1
public class calculateArea{
public Value;
calculateArea(){
value = new Value();
}
public double area(){
value.setRadious(2.34);//or set ACCORDINGLY
return 3.14 * value.radious * value.radious;
}
}
Add getters to class Value.
public class Value {
public double radious;
public double lenght;
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
public double getLenght() {
return this.lenght;
}
public double getRadious() {
return this.radious;
}
}
Make an instance of class 1
public class calculateArea{
public Value;
calculateArea(){
value = new Value();
}
public double area(){
value.setRadious(2.34);//or set ACCORDINGLY
return 3.14 * value.radious * value.radious;
}
}
edited Nov 22 '18 at 15:24
answered Nov 22 '18 at 12:40
Isuru NuwanthilakaIsuru Nuwanthilaka
1036
1036
you can't call value.setRadious like that. this is (at best) an incomplete answer
– Stultuske
Nov 22 '18 at 13:07
@Stultuske so tell the reason why you can't call value.setRadious() like that.
– Isuru Nuwanthilaka
Nov 22 '18 at 13:23
because it's not in a method or block.
– Stultuske
Nov 22 '18 at 13:31
@Stultuske editted.Thanks.
– Isuru Nuwanthilaka
Nov 22 '18 at 15:09
add a comment |
you can't call value.setRadious like that. this is (at best) an incomplete answer
– Stultuske
Nov 22 '18 at 13:07
@Stultuske so tell the reason why you can't call value.setRadious() like that.
– Isuru Nuwanthilaka
Nov 22 '18 at 13:23
because it's not in a method or block.
– Stultuske
Nov 22 '18 at 13:31
@Stultuske editted.Thanks.
– Isuru Nuwanthilaka
Nov 22 '18 at 15:09
you can't call value.setRadious like that. this is (at best) an incomplete answer
– Stultuske
Nov 22 '18 at 13:07
you can't call value.setRadious like that. this is (at best) an incomplete answer
– Stultuske
Nov 22 '18 at 13:07
@Stultuske so tell the reason why you can't call value.setRadious() like that.
– Isuru Nuwanthilaka
Nov 22 '18 at 13:23
@Stultuske so tell the reason why you can't call value.setRadious() like that.
– Isuru Nuwanthilaka
Nov 22 '18 at 13:23
because it's not in a method or block.
– Stultuske
Nov 22 '18 at 13:31
because it's not in a method or block.
– Stultuske
Nov 22 '18 at 13:31
@Stultuske editted.Thanks.
– Isuru Nuwanthilaka
Nov 22 '18 at 15:09
@Stultuske editted.Thanks.
– Isuru Nuwanthilaka
Nov 22 '18 at 15:09
add a comment |
Declare getters and setters for Value-class:
public class Value {
private double radious;
private double lenght;
public Value(double radious, double length) {
this.radious = radious;
this.length = length;
}
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
public double getRadious() {
return this.radious;
}
public double getLength() {
return this.length;
}
}
Instantiate the object with some variables:
Value value = new Value(2.0,3.0);
Add Constructor to CalculateArea class:
public class calculateArea {
private Value value;
public calculateArea(Value value) {
this.value = value;
}
public double area()
{
return 3.14*value.getRadious()*value.getRadious();
}
}
Instantiate:
calculateArea cArea= new calculateArea(value);
And print result to console in main()
method:
System.out.println(cArea.area());
you forgot to mention why the code you posted won't compile. this is not a good answer, the errors are repeated in your answer
– Stultuske
Nov 22 '18 at 13:07
add a comment |
Declare getters and setters for Value-class:
public class Value {
private double radious;
private double lenght;
public Value(double radious, double length) {
this.radious = radious;
this.length = length;
}
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
public double getRadious() {
return this.radious;
}
public double getLength() {
return this.length;
}
}
Instantiate the object with some variables:
Value value = new Value(2.0,3.0);
Add Constructor to CalculateArea class:
public class calculateArea {
private Value value;
public calculateArea(Value value) {
this.value = value;
}
public double area()
{
return 3.14*value.getRadious()*value.getRadious();
}
}
Instantiate:
calculateArea cArea= new calculateArea(value);
And print result to console in main()
method:
System.out.println(cArea.area());
you forgot to mention why the code you posted won't compile. this is not a good answer, the errors are repeated in your answer
– Stultuske
Nov 22 '18 at 13:07
add a comment |
Declare getters and setters for Value-class:
public class Value {
private double radious;
private double lenght;
public Value(double radious, double length) {
this.radious = radious;
this.length = length;
}
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
public double getRadious() {
return this.radious;
}
public double getLength() {
return this.length;
}
}
Instantiate the object with some variables:
Value value = new Value(2.0,3.0);
Add Constructor to CalculateArea class:
public class calculateArea {
private Value value;
public calculateArea(Value value) {
this.value = value;
}
public double area()
{
return 3.14*value.getRadious()*value.getRadious();
}
}
Instantiate:
calculateArea cArea= new calculateArea(value);
And print result to console in main()
method:
System.out.println(cArea.area());
Declare getters and setters for Value-class:
public class Value {
private double radious;
private double lenght;
public Value(double radious, double length) {
this.radious = radious;
this.length = length;
}
public void setRadious(double radious) {
this.radious = radious;
}
public void setLenght(double lenght) {
this.lenght = lenght;
}
public double getRadious() {
return this.radious;
}
public double getLength() {
return this.length;
}
}
Instantiate the object with some variables:
Value value = new Value(2.0,3.0);
Add Constructor to CalculateArea class:
public class calculateArea {
private Value value;
public calculateArea(Value value) {
this.value = value;
}
public double area()
{
return 3.14*value.getRadious()*value.getRadious();
}
}
Instantiate:
calculateArea cArea= new calculateArea(value);
And print result to console in main()
method:
System.out.println(cArea.area());
edited Nov 22 '18 at 15:49
answered Nov 22 '18 at 12:48
nirfreanirfrea
443
443
you forgot to mention why the code you posted won't compile. this is not a good answer, the errors are repeated in your answer
– Stultuske
Nov 22 '18 at 13:07
add a comment |
you forgot to mention why the code you posted won't compile. this is not a good answer, the errors are repeated in your answer
– Stultuske
Nov 22 '18 at 13:07
you forgot to mention why the code you posted won't compile. this is not a good answer, the errors are repeated in your answer
– Stultuske
Nov 22 '18 at 13:07
you forgot to mention why the code you posted won't compile. this is not a good answer, the errors are repeated in your answer
– Stultuske
Nov 22 '18 at 13:07
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431047%2fget-some-object-of-one-class-and-use-in-another-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
add getters, but you'll also need an instance of your first class there
– Stultuske
Nov 22 '18 at 12:30