Explain what will happen if the lines indicated

Assignment Help JAVA Programming
Reference no: EM131578926

Consider the following code which implements the add method in the DList class from the course videos:public void add(int pIndex, Integer pData) throws IndexOutOfBoundsException {

if (pIndex < 0 || pIndex > getSize())
throw new IndexOutOfBoundsException();

if (pIndex == getSize()) { //adding node to the end of the list
Node newNode = new Node(pData, getTail(), null);

if (isEmpty())
setHead(newNode); //////////LINE 1
else
getTail().setNext(newNode); //////////LINE 2

setTail(newNode);
}
else {
Node node = getNodeAt(pIndex);
Node newNode = new Node(pData, node.getPrev(), node);

if (pIndex != 0)
node.getPrev().setNext(newNode);

node.setPrev(newNode);
if (pIndex == 0)
setHead(newNode);
}

setSize(getSize() + 1);
}
Explain what will happen if the lines indicated are swapped.

Reference no: EM131578926

Questions Cloud

Discuss violent video games lead to criminal behavior : Let's say the study concludes that boys who play violent video games behave more violently after the experiment
What are the benefits and drawbacks of buying tips : Please explain the relationship between TIPS and the consumer price index. What are the benefits and drawbacks of buying TIPS?
Explain a new operations strategy for selected organizatio : Explain a new operations strategy for the selected organization based on the four competitive priorities (i.e., cost, quality, time, and flexibility).
Locate a scholarly article regarding police liability : Locate a scholarly article regarding police liability. Summarize the article and formulate it into an annotated bibliography
Explain what will happen if the lines indicated : Consider the code which implements the add method in the DList class from the course videos
How does the given scheme change the standard deviation : On a true-false test, the score is often computed by subtracting the number of wrong answers from the number of right ones and converting.
Prepare one short paper based on the smackey dog food inc : Required: During our course, each of you will prepare one short (five to seven pages, double-spaced) paper based on the Smackey Dog Food Inc. case facts above
Define the methods listed : Write a program that prompts the user to enter 5 integer numbers. Once the user enters the 5 numbers, the program must determine and output the average
Problem relan intuitive law of probability : This problem derives an intuitive law of probability known as the law of large numbers from Chebyshev's law. Informally, the law of large numbers says.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Design a boolean function named isprime,

A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Des..

  Implement avl trees that allows both iterative traversal

implement avl trees that allows both iterative traversal and recursive traversal.iterative traversal is fairly easy if

  Create an application named numbers.

Create an application named Numbers. The Numbers class should have non-static public methods named sum and difference, each taking a pair of int variables as arguments. As you might expect, the sum method should add the two integers and return the..

  Writing a program that parses

The programming project involves writing a program that parses, using recursive descent, a GUI definition language defined in an input file and generates the GUI that it defines.

  Implement a personal scheduler windows application

Implement a personal scheduler Windows application - Entries can be enabled and disabled: Enabled schedule entries appear dark in the main window, and disabled entries appear grayed out in the list.

  Write program in java for total amount of customer-s order

Write down program in Java which would ask for clerk to enter total amount of customer's order. Program will then compute seven percent (7%) sales tax.

  Implement an intrusion detection system in java

You are to implement an intrusion detection system in java. Calculate a threshold for detecting an intrusion. The threshold is 2*(Sums of weights).

  Create program perform error-checking on the initial values

Create a program called Date.java to perform error-checking on the initial values, for instance: fields month, day, and year. Also, provide a method nextDay() to increment the day by one.

  Splits the word into a unicode character array

Write methods that take a word input by the user and then- splits the word into a unicode character array. determines if the input word is a palindrome - the same frontwards and backwards.

  Rectangular and cylindrical coordinates

Write a program to convert between rectangular and cylindrical coordinates, based upon user input.

  Prepare a program to triple each number in the list

Write a program that will read in a list of numbers, triple each number in the list and print the result - Write a program that will read in 2 numbers per line, and print the sum.

  Better programming language

1. Describe three features that make Java a better programming language than C to write secure programs.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd