Skip to Content
Java How to Program, Early Objects, 11th Edition
book

Java How to Program, Early Objects, 11th Edition

by Paul J. Deitel, Harvey Deitel
June 2017
Beginner
1296 pages
69h 23m
English
Pearson
Content preview from Java How to Program, Early Objects, 11th Edition
... i++) { // populate array
27            data[i] = 10 + generator.nextInt(90);
28         }
29
30         System.out.printf("%s%n%n", Arrays.toString(data)); // display array
31
32         // get input from user
33         System.out.print("Please enter an integer value (-1 to quit): ");
34         int searchInt = input.nextInt();
35
36         // repeatedly input an integer; -1 terminates the program
37         while (searchInt != -1) {
38            int position = linearSearch(data, searchInt); // perform search
39
40            if (position == -1) { // not found
41               System.out.printf("%d was not found%n%n", searchInt);
42            }
43            else { // found
44               System.out.printf("%d was found in position %d%n%n",
45                  searchInt, position);
46            }
47
48            // get input from user
49            System.out.print("Please enter an integer value (-1 to quit): ");
50 searchInt ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17

Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17

Kishori Sharan, Adam L. Davis
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Java in a Nutshell, 8th Edition

Java in a Nutshell, 8th Edition

Benjamin J. Evans, Jason Clark, David Flanagan

Publisher Resources

ISBN: 9780134751962