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
Nookie1986 [14]
3 years ago
15

Java programming

Computers and Technology
1 answer:
Marat540 [252]3 years ago
5 0

Answer:

The program in Java is as follows:

import java.util.*;

public class Main {

public static void removeDuplicate(ArrayList<Integer> list){

 ArrayList<Integer> newList = new ArrayList<Integer>();

 for (int num : list) {

  if (!newList.contains(num)) {

   newList.add(num);  }  }

 for (int num : newList) {

     System.out.print(num+" ");  } }

public static void main(String args[]){

 Scanner input = new Scanner(System.in);

 ArrayList<Integer> list = new ArrayList<Integer>();

 System.out.print("Enter ten integers: ");

 for(int i = 0; i<10;i++){

     list.add(input.nextInt());  }

 System.out.print("The distinct integers are: ");

 removeDuplicate(list);

}}

Explanation:

This defines the removeDuplicate function

public static void removeDuplicate(ArrayList<Integer> list){

This creates a new array list

 ArrayList<Integer> newList = new ArrayList<Integer>();

This iterates through the original list

 for (int num : list) {

This checks if the new list contains an item of the original list

  if (!newList.contains(num)) {

If no, the item is added to the new list

   newList.add(num);  }  }

This iterates through the new list

 for (int num : newList) {

This prints every element of the new list (At this point, the duplicates have been removed)

     System.out.print(num+" ");  } }

The main (i.e. test case begins here)

public static void main(String args[]){

 Scanner input = new Scanner(System.in);

This declares the array list

 ArrayList<Integer> list = new ArrayList<Integer>();

This prompts the user for ten integers

 System.out.print("Enter ten integers: ");

The following loop gets input for the array list

<em>  for(int i = 0; i<10;i++){ </em>

<em>      list.add(input.nextInt());  } </em>

This prints the output header

 System.out.print("The distinct integers are: ");

This calls the function to remove the duplicates

 removeDuplicate(list);

}}

You might be interested in
The laws governing search and seizure in the public sector are much more straightforward than those in the private sector. TRUE
Lapatulllka [165]

Answer:

True

Explanation:

Because of the contract that you have agreed to when joining the work force. Which is different from the private sector.

7 0
3 years ago
What should be used when performing vehicle maneuvers?
IrinaVladis [17]

a wand .............

7 0
4 years ago
Many businesses use robotic solutions. Which department of the food and beverage industry uses robotic solutions on a large scal
Alenkinab [10]

Answer:

Its packing you're welcome :)

Explanation:

7 0
4 years ago
Read 2 more answers
What is an establishing shot, and when is it an appropriate shot choice in a film?
Mila [183]
Here's the official definition:

It is generally a long or extreme-long shot<span> at the beginning of a scene indicating where, and sometimes when, the remainder of the scene takes place. </span>Establishing<span> shots were more common during the classical era of filmmaking than they are now.</span>
4 0
4 years ago
Read 2 more answers
What will be the output of the following code?int p = 3,ch = 2;switch(ch){case 1: System. Out. Println("The square is: " + p*p);
kodGreya [7K]
“The cube is: 27”
or p^3
The switch function uses the ch int and identifies a matching case. Because ch is 2
We use case 2
Thus the following line at the top is printed.
Then automatically breaks the function, so we don’t continue.
4 0
2 years ago
Other questions:
  • What version of android did nexus one run?
    14·1 answer
  • As the Sunrise hospital implements an EHR, the coding staff requests a new system that will enhance productivity, accuracy, and
    15·1 answer
  • What are the pros and cons of using the Internet for researching career information?
    14·2 answers
  • When determining the amount of RAM necessary for a computer you wish to purchase, what should you consider?
    7·1 answer
  • Consumers may receive an​ e-mail, supposedly from their bank or credit card​ company, saying that their​ account's security has
    10·1 answer
  • Someone wanna be in a meeting with me <br><br><br> Code: rrx-ofrw-ocj
    5·2 answers
  • What method do phishing and spoofing scammers use
    12·1 answer
  • 22. The Disc Drive is also known as the:
    15·1 answer
  • What is multimedia computer system​
    7·1 answer
  • When users connect to the network, they use a basic hardware terminal to access a desktop hosted on a virtualization server. wha
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!