Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

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());
expand button
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());
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 +
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education