Okay so I'm totally a beginner and just learning this in class. Can anyone tell me what I'm doing wrong? When I run this code it's supposed to tell me that myMonkey and myFavoriteMonkey are the same color... but I keep getting a null value for the output...
I've got this on another java page(?)
public class Monkey2 {
private String color;
private int weight;
public void setColor(String color) {
this.color = color;
}
public String getColor(){
return color;
}
public void setWeight(int w){
this.weight = weight;
}
public int getWeight(){
return weight;
}
public void swing() {
System.out.println("Swinging");
}
}
and this on a separate page
public class MonkeyApp {
public static void main(String[] args) {
Monkey2 myMonkey = new Monkey2();
Monkey2 myMonkey2 = new Monkey2();
Monkey2 myFavoriteMonkey = myMonkey;
String myFavoriteMonkeyColor = "black";
int myMonkeyWeight = 75;
myMonkey.setWeight(myMonkeyWeight);
myFavoriteMonkey.swing();
System.out.println("myMonkey: " + myMonkey +
" color: " + myMonkey.getColor() +
" weight: " + myMonkey.getWeight());
System.out.println("myMonkey2: " + myMonkey2 +
" color: " + myMonkey2.getColor() +
" weight: " + myMonkey2.getWeight());
System.out.println("myFavoriteMonkey: " + myFavoriteMonkey +
" color: " + myFavoriteMonkey.getColor() +
" weight: " + myFavoriteMonkey.getWeight());
}
}