1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nikdorinn [45]
4 years ago
13

Create a client that does the following: - Creates a SinglyLinkedList of Integer - Adds the number 3 to the list using the addFi

rst method - Adds the number 2 to the list using the addFirst method - Adds the number 1 to the list using the addFirst method - Adds the number 0 to the list using the addFirst method - Adds the number 4 to the list using the addLast method - Adds the number 5 to the list using the addLast method - Prints out the list using the toString method
Computers and Technology
1 answer:
blagie [28]4 years ago
8 0

Explanation:

We first create a linkedlist named int_list which is empty at the moment.

Next we start adding some integers into the int_list by using addFirst() function. The addFirst() function is different from add() function. The add() function sequencially adds the data into the list whereas addFirst() function always adds the data at the first position.

Next we added few integers into the int_list by using addLast() function. addLast() function always adds the data at the last position of the list.

Lastly, we print the int_list using toString() method which returns the string representation of the list data.

For Example:

Using add() function

int_list.add(1)

output = int_list = [1]

int_list.add(2)

output = int_list = [1, 2]

int_list.add(3)

output = int_list = [1, 2, 3]

Now using addFirst() function

int_list.addFirst(1)

output = int_list = [1]

int_list.addFirst(2)

output = int_list = [2, 1]

int_list.addFirst(3)

output = int_list = [3, 2, 1]

Now using addLast() function

int_list.addLast(4)

output = int_list = [3, 2, 1, 4]

int_list.addLast(5)

output = int_list = [3, 2, 1, 4, 5]

Java Code:

import java.io.*;  

import java.util.LinkedList;  

public class SinglyLinkedList {  

  public static void main(String args[]) {  

     LinkedList int_list = new LinkedList();  

     // use add() method to add elements in the list  

     int_list.addFirst(3);  

     int_list.addFirst(2);  

     int_list.addFirst(1);  

     int_list.addFirst(0);  

     int_list.addLast(4);

     int_list.addLast(5);

   System.out.println("Here is the list: " + int_list.toString());    

  }  

}

Output:

Here is the list: [0,1,2,3,4,5]

You might be interested in
When text is used as a Hyperlink, it is usually underlined and appears as a different color.
Artist 52 [7]
True it usually shows up with a blue underline
7 0
3 years ago
In implementing Security Life Cycle:__________
Dvinal [7]

Answer:

b) one needs to follow through all phases, assessment, design, deploy and manage security

Explanation:

The security life cycle is a process in which it involves the security artifacts for developing the software through a lifecycle. It contains a detailed plan that derives how to create an application form

At the time when the requirements and activity related to design is finished the next step is the software implementation. In this, the developers begins with the coding as per the requirements and designs discussed in the last step

Therefore according to the given options, the second option is correct

7 0
3 years ago
Some applications required advanced storage solutions are available to provide fault tolerance and high performance.
katen-ka-za [31]
A. True

This is because not all applications can run with low/small storage.
3 0
3 years ago
Many bookstores have closed since the rise of the Internet. What type of
agasfer [191]

Answer:

D

Explanation:

If bookstores, which are businesses that have to turn a profit, close down because of the internet, this is primairly economic impact.

3 0
3 years ago
Each drop-down menu.
solniwko [45]

'Splitting' involves dividing a single column into multiple columns.

'Validation' involves checking the data for correctness. (there slight possibility I am wrong for this one)

I hope I provided some great assistance for you, have a good day, young programer.

7 0
3 years ago
Other questions:
  • To evaluate trends in the workforce, investigate
    14·1 answer
  • #Write a function called "angry_file_finder" that accepts a #filename as a parameter. The function should open the file, #read i
    13·1 answer
  • A display that is thin, flexible, light, and easy to read in all types of light is
    9·2 answers
  • 1. A formula =A1+B2 is in cell D8. If you copy that formula to cell D9, what is the new formula in cell D9?
    7·1 answer
  • The network services and facilities that users interact with are provided by
    11·1 answer
  • Which is the correct sequence of steps for opening a new document?
    10·2 answers
  • The operation of early electronic computing devices required:
    8·1 answer
  • . Convert your age into binary and then to hexadecimal. Show your work.
    5·1 answer
  • Write a program that will input miles traveled and hours spent in travel. The program will determine miles per hour. This calcul
    5·1 answer
  • Which are the two alternatives for pasting copied data in a target cell or a group of cells?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!