Question: So if I have two objects from the main class and I ' m trying to add them together. how can I create a

"So if I have two objects from the main class and I'm trying to add them together. how can I create a method to add whatever those two objects?
MA03
I tried to do it here but I could not finish it.
package Bright;
public class partic {
public int conNumber;
public partic(int number){
conNumber = number;
}
public partic add(partic sum){
return null;
}
}
--------------------------------
package Bright;
public class particDemo {
public static void main (String[] args){
partic val1= new partic(23);
System.out.println(""val one is ""+ val1.conNumber);
partic val2= new partic(54);
System.out.println(""val one is ""+ val2.conNumber);
partic sum;
sum = val1.add(val2);
System.out.println(""The sum: ""+ sum);
}
}"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!