please help me understand the following code in java on the topic: Generic Class some questions I have is why item1 = 9999 and what is happening in this code.
please help me understand the following code in java on the topic: Generic Class some questions I have is why item1 = 9999 and what is happening in this code.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
please help me understand the following code in java on the topic: Generic Class
some questions I have is why item1 = 9999 and what is happening in this code.
![Tripleltem Manager.java:
public class TripleItemManager {
public static void main(String[] args) {
5555, 6666);
// TripleItem class with Integers
TripleItem<Integer> triInts = new TripleItem<Integer>(9999,
// TripleItem class with Shorts
TripleItem<Short> triShorts new TripleItem<Short>((short) 99,
(short) 55, (short)66);
}
}
// Try methods from TripleItem
triInts.printAll();
System.out.println("Min: " + triInts.minItem() + "\n");
triShorts.printAll();
System.out.println("Min:
(9999,5555,6666)
Min: 5555
(99,55,66)
Min: 55
11
+ triShorts.minItem());](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F40a93fbf-cd84-46cf-939a-402485a39dd9%2F548cc878-3a6f-4874-81de-814634ee5169%2F5tvkh3_processed.png&w=3840&q=75)
Transcribed Image Text:Tripleltem Manager.java:
public class TripleItemManager {
public static void main(String[] args) {
5555, 6666);
// TripleItem class with Integers
TripleItem<Integer> triInts = new TripleItem<Integer>(9999,
// TripleItem class with Shorts
TripleItem<Short> triShorts new TripleItem<Short>((short) 99,
(short) 55, (short)66);
}
}
// Try methods from TripleItem
triInts.printAll();
System.out.println("Min: " + triInts.minItem() + "\n");
triShorts.printAll();
System.out.println("Min:
(9999,5555,6666)
Min: 5555
(99,55,66)
Min: 55
11
+ triShorts.minItem());

Transcribed Image Text:Tripleltem.java:
public class TripleItem <TheType extends Comparable<TheType>> {
private TheType iteml; // Data value 1
private TheType item2; // Data value 2
private TheType item3; // Data value 3
public TripleItem(TheType il, TheType 12, TheType i3) {
item1
item2
item3
}
// Print all data member values
public void printAll() {
System.out.println("(" + item1 +
")") ;
}
il;
12;
13;
// Return min data member value
public TheType minItem() {
TheType minVal;
item
}
minval iteml;
if (item2.compareTo (minVal) < 0) {
minval = item2;
}
if (item3.compareTo (minVal) < 0) {
minVal =
item3;
}
return minVal;
+ item2 +
I
// Holds min item value, init to first
+ item3 +
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education