Term 2 - Lesson 12: Wrapper Classes

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Wrapper Classes

* "Wraps" a primitive in a class type * One for each of the primitive types Ex. Double ----> double Integer ----> int

"Integer" Class

* Wrapper class for int * Implements "Comparable", so there must be a compareTo method

Which of the following isn't a wrapper class? A) Double B) Integer C) String

C) String

Which of the following isn't a method of the "Integer" wrapper class? A) toString B) equals C) Integer D) MAX_VALUE E) valueOf

D) MAX_VALUE

Example of using the "Double" class

Double n1 = new Double(98.232); ArrayList <Double> h = new ArrayList <Double> (); h.add(n1);

What is the maximum value an Integer can hold?

Integer.MAX_VALUE;

Is the output of the following a positive or negative value? Integer n1 = new Integer(45); Integer n2 = new Integer(56); System.out.println(n1.compareTo(n2));

Negative

"Double" Class

Wrapper class for double

How would you properly add the value 75 to the following ArrayList? ArrayList<Integer> temps = new ArrayList<Integer>();

temps.add(new Integer(75));


Ensembles d'études connexes

ATI- Med-Surg: Cardiovascular & Hematology

View Set

2023 AL Life Insurance Only - Key Facts

View Set

Eco quiz #7b (Modules 34,35) (Week 9)

View Set

microbiology 2023 chapter one. that i made

View Set