Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Explain the difference in Java between int and Integer. 2. Write a line of Java code to... a) Declare an ArrayList of floating point
1. Explain the difference in Java between int and Integer.
2. Write a line of Java code to...
a) Declare an ArrayList of floating point numbers (doubles).
b) Generate a random double in the interval and add it to the ArrayList you created in A.
3. Consider the following Java declarations:
ArrayList list = new ArrayList();
ArrayList x = new ArrayList();
Integer one = new Integer(1);
int two = 2;
Determine whether each line below would COMPILE or cause a COMPILE-TIME ERROR. Briefly explain your reasoning.
a) list.add( two );
b) list.add( one );
c) list.add( one );
d) x.add( one );
e) x.add( two );
f) x.add( one.toString() );
g) x.add( two.toString() );
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started