Question: / * * Given an add method: * Adds a new value to the end of the list. * * @param value the integer value

/** Given an add method:
* Adds a new value to the end of the list.
*
* @param value the integer value to be added to the list
*/
public void add(int value){
if (front == null){
front = new ListNode(value);
} else {
ListNode current = front;
while (current.next != null){
current = current.next;
}
current.next = new ListNode(value);
}
}
Write a function: public void stutter() This method will double the size of the list by replacing every integer in the list with two of that integer. If the list is empty, simply return. For example, suppose a variable list stores the values [1,8,19,4,17]. After a call of list.stutter(), it should store [1,1,8,8,19,19,4,4,17,17].

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!