changxi wu

Greenhorn
+ Follow
since Nov 17, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by changxi wu

8 years ago

Recaip Sanli wrote:So I need to touch elements of Photograph object array, but I can't. I entered hard value of 1 to touch them there's still an error:

Album.java:17: error: bad operand types for binary operator '+'
           priceResult = photos[1] + priceResult;
                                   ^
 first type:  Photograph
 second type: double
1 error



Should be like this. there is only one array. And photos[1] is Photograph, you should get the price by calling the instance method.

for(int i=0;i<photos.length;i++){
    priceResult = photos[i].getPrice() + priceResult;
}
8 years ago