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
Whats the relationship between the CPU and motherboard
Mashcka [7]

Answer:

Both perform processes vital to running the computer's operating system and programs -- the motherboard serves as a base connecting all of the computer's components, while the CPU performs the actual data processing and computing.

Explanation:

6 0
4 years ago
A pointing device used mainly for computer games is known as
kolbaska11 [484]

Answer: Joystick is the only one that makes sense, a stylus and digitizer are both used on drawing tablets, not computer games.

5 0
2 years ago
On a printed circuit board, electronic components will be mounted from the
Likurg_2 [28]
On a printed circuit board, electronic parts will be mounted from the substrate side of the board. The leads jab through the substrate and the copper sheeting that has been carved. The leads are then soldered to the copper.

I hope the answer will help you. 
3 0
3 years ago
Proponents of Internet freedom see its _____________ as providing protection for unpopular expression; proponents of greater Int
diamong [38]

Answer:

anonymity

Explanation:

<h2><u>Fill in  the blanks </u></h2>

Proponents of Internet freedom see its <u>anonymity </u>as providing protection for unpopular expression; proponents of greater Internet control see it as the Internet's greatest danger.

6 0
3 years ago
11. Which one of the following buttons is used for paragraph alignment?<br>​
Luba_88 [7]

Answer:

<em>C</em>

Explanation:

Option <em>A </em>is used for line spacing.

Option <em>B </em>is used for right indent.

Option <em>C</em> is used for right paragraph alignment.

Option <em>D</em> is used for bullet points.

The button used for paragraph alignment would be option <em>C</em>.

3 0
4 years ago
Other questions:
  • Which wireless device does the manager most likely have before being offered the upgrade by her supervisor?
    8·2 answers
  • Prove that for every nfa with an arbitrary number of final states there is an equivalent nfa with only one final state. Can we m
    8·1 answer
  • To what would you compare the transport layer?
    12·1 answer
  • Define a class called Counter. An object of this class is used to count things so it records a count that is a non-negative whol
    12·1 answer
  • WILL GIVE BRAINLIEST!!!!!!!
    9·1 answer
  • As marketing manager, you need to have ( blank) skills and (blank) skills.
    11·1 answer
  • Evaluate if the following function is a good candidate to be placed in a library. Why or why not?
    10·2 answers
  • Using these Web sites for guidance, write a definition in your own words for five of the terms listed below.
    8·1 answer
  • You are creating a query for a website. The query
    5·1 answer
  • To stored three characters a computer occupies. Bytes memory space
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!