I have recently started learning classes and object and tried this simple code. here I want to print what rooms have more element so i have implemented if-else but when I try to compile, it is giving me error and I can't able to understand so what correction should I have to made
Error is can't find symbol (room1.Home>room2.Home)
Somebody has corrected the code tags in your post (you didn't quite get them right). Doesn't it look better Unfortunately your code isn't indented correctly, and that shows.
Where are you learning programming? Your object‑orientation is unfortunately not complete. Make all the fields private, and initialise them in the constructor. Give access to the fields with getXXX() methods. Don't calculate the sum of items in HomeTest; give Home a totalItems() or similar method, Use that to calculate and return the totals.
Your room objects don't have a member called Home, which is what the compiler is complaining about.
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad: