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
yaroslaw [1]
2 years ago
7

Create a map using the Java map collection. The map should have 4 entries representing students. Each entry should have a unique

student ID for the key and a student name for the element value. The map content can be coded in directly, you do not have to allow a user to enter the map data. Your program will display both the key and the value of each element.
Computers and Technology
1 answer:
Angelina_Jolie [31]2 years ago
4 0

Answer:

In Java:

import java.util.*;  

public class Main{

   public static void main(String[] args) {

       Map<String, String> students = new HashMap<>();

       students.put("STUD1", "Student 1 Name");

       students.put("STUD2", "Student 2 Name");

       students.put("STUD3", "Student 3 Name");

       students.put("STUD4", "Student 4 Name");

       for(Map.Entry m:students.entrySet()){  

           System.out.println(m.getKey()+" - "+m.getValue());    }  

}}

Explanation:

This creates the map named students

       Map<String, String> students = new HashMap<>();

The next four lines populates the map with the ID and name of the 4 students

<em>        students.put("STUD1", "Student 1 Name");</em>

<em>        students.put("STUD2", "Student 2 Name");</em>

<em>        students.put("STUD3", "Student 3 Name");</em>

<em>        students.put("STUD4", "Student 4 Name");</em>

This iterates through the map

       for(Map.Entry m:students.entrySet()){  

This prints the details of each student

           System.out.println(m.getKey()+" - "+m.getValue());    }  

You might be interested in
5. Which one of the following statements is true for spell checkers? A. Most spell checkers flag inappropriate word usage. B. A
Strike441 [17]
It is b, as some word checkes don't recognize modern slangs. 
3 0
2 years ago
In needs analysis: Group of answer choices the costs of different physical network design alternatives are assessed the rate of
Ludmilka [50]

Answer:

the goal is to understand what users and applications the network will support.

Explanation:

A traditional network design approach is said to follow the structured systems of analysis as well design process that is similar to that which is used in building such applications. The main goal of the application developers is understand and study the needs of the users and also the application which the network will support.

5 0
2 years ago
Which of the following characters is not allowed for java variable names
Rainbow [258]
The variables must begin with a letter of the alphabet, a dollar sign or a underscore. After the first character you may add numbers as well. All special characters besides the dollar sign and underscore and not allowed in variables.
8 0
3 years ago
What's the smallest part of a computer
Murljashka [212]

Answer:

A byte

Explanation:

I just had that question on my quiz

7 0
3 years ago
Read 2 more answers
When installing a Windows 10 an already installed Windows 7 what happen​
astra-53 [7]

Answer:

are u updating it? or u r rooting it?

4 0
2 years ago
Read 2 more answers
Other questions:
  • PLEASE HURRY
    6·1 answer
  • In C please:
    5·1 answer
  • Implement RandMultipByVal function, which gets one integervariable as its argument
    12·1 answer
  • What are 3 ways to select an entire document?
    15·1 answer
  • Is a biometric system an input, output, storage or soft device?​
    6·1 answer
  • Identify five type of application software​
    12·2 answers
  • Anne wants to hide her age by converting it from 13 to 1101. Which number system is Anne converting to?
    13·1 answer
  • Compare mini and mainframe computer in terms of speed,memory and storage​
    15·1 answer
  • How are the waterfall and agile methods of software development similar?
    13·1 answer
  • A small square at the right corner of the table is what?​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!