0
class Main {
public static void main(String[] args) {

Book crimeAndPunishment = new Book();
crimeAndPunishment.name = "Crime and Punishment";
crimeAndPunishment.author = "Fyodor Dostoevsky";
crimeAndPunishment.numberOfPages = 600;

Book meditations = new Book();
meditations.name = "Meditations on first philosophy";
meditations.author = "René Descartes";
meditations.numberOfPages = 300;

Book languageInstinct = new Book();
languageInstinct.name = "The Language Instinct";
languageInstinct.author = "Steven Pinker";
languageInstinct.numberOfPages = 400;

Hi, I'm new to java and I've created a few book objects but need to find the book with the most pages. I have looked up how to use for loops and while loops but I'm not sure what condition should be set.

tld
  • 11
  • 1
  • 1
    Add them to a list or an array and then see this https://stackoverflow.com/q/35281335/5292302 – Petter Friberg Apr 23 '22 at 05:39
  • @Basil OP wants the object not the max value, I suggest you change dup to my link or something better – Petter Friberg Apr 23 '22 at 05:48
  • @PetterFriberg Can you use the “Edit” button to add your link as a second original item? The Stack Overflow user interface for iPhone is currently broken, and won’t physically let me use that Edit feature. – Basil Bourque Apr 23 '22 at 05:54
  • @BasilBourque sorry I have no gold in Java, anyway np if question survives these comments are enough – Petter Friberg Apr 23 '22 at 05:59

0 Answers0