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
just olya [345]
4 years ago
12

Write a statement to create a Google Guava Multimap instance which contains student ids as keys and the associated values are st

udent profiles.
Computers and Technology
1 answer:
Sergeu [11.5K]4 years ago
8 0

Answer: provided in the explanation section

Explanation:

Note: take note for indentation so as to prevent error.

So we import com.google.common.collect.Multimap;

import java.util.Collection;

import java.util.Map;

class Main {

   public static void main(String[] args) {

       // key as studentId and List of Profile as value.

       Multimap<String,Profile> multimap = ArrayListMultimap.create();

       multimap.put("id1", new ExamProfile("examStudentId1"));

       multimap.put("id1", new ELearningProfile("userId1"));

       multimap.put("id2", new ExamProfile("examStudentId2"));

       multimap.put("id2", new ELearningProfile("userId2"));

       // print the data now.

       for (Map.Entry<String, Collection<Profile>> entry : multimap.entrySet()) {

           String key = entry.getKey();

           Collection<String> value =  multimap.get(key);

           System.out.println(key + ":" + value);

       }

   }

}

// assuming String as the studentId.

// assuming Profile as the interface. And Profile can multiple implementations that would be

// specific to student.

interface Profile {

}

class ExamProfile implements Profile {

   private String examStudentId;

   public ExamProfile(String examStudentId) {

       this.examStudentId = examStudentId;

   }

}

class ELearningProfile implements Profile {

   private String userId;

   public ELearningProfile(String userId) {

       this.userId = userId;

   }

}

This code is able to iterate through all entries in the Google Guava multimap and display all the students name in the associated students profile.

You might be interested in
Define and use in your program the following functions to make your code more modular: convert_str_to_numeric_list - takes an in
Lelechka [254]

Answer:

In Python:

def convert_str_to_numeric_list(teststr):

   nums = []

   res = teststr.split()

   for x in res:

       if x.isdecimal():

           nums.append(int(x))

       else:

           nums = []

           break;

   return nums

def get_avg(mylist):

   if not len(mylist) == 0:

       total = 0

       for i in mylist:

           total+=i

       ave = total/len(mylist)

   else:

       ave = "None"

   return ave

def get_min(mylist):

   if not len(mylist) == 0:

       minm = min(mylist)

   else:

       minm = "None"

   return minm

def get_max(mylist):

   if not len(mylist) == 0:

       maxm = max(mylist)

   else:

       maxm = "None"

   return maxm

mystr = input("Enter a string: ")

mylist = convert_str_to_numeric_list(mystr)

print("List: "+str(mylist))

print("Average: "+str(get_avg(mylist)))

print("Minimum: "+str(get_min(mylist)))

print("Maximum: "+str(get_max(mylist)))

Explanation:

<em>See attachment for complete program where I use comment for line by line explanation</em>

Download txt
7 0
3 years ago
A standard computer monitor is 1024 pixels wide and 768 pixels tall
Annette [7]
If this is a true or false question the answer is true
8 0
4 years ago
How to do a row of circles on python , with the commands , picture is with it .
kotykmax [81]

Answer:

o.o

Explanation:

5 0
3 years ago
what technology is used to prove that an object is a living organism, and what is the piece of evidence used to prove that?
den301095 [7]

Cells and microscope.

7 0
3 years ago
Donna is in the Outlook Today window and clicks the F1 button on her keyboard. What is Donna most likely trying to do?
Jobisdone [24]
I believe the answer is D. <span>use the Help feature of Outlook
In general, f1 is the shortcut to access help feature in almost all computer program.
Other than using this method, Donna could also use 'tell me what to do' phrase in the query box in order to access the feature.</span>
8 0
3 years ago
Read 2 more answers
Other questions:
  • Which spereadsheet type will determine<br> how well a bussiness has done over the past year
    11·1 answer
  • You want to find information about Paris, France in the last five years, written in English. What is the best way to search for
    5·2 answers
  • Which of the following is a central feature of agroup?interactionmutual influenceinterdependenceall of the given options
    10·1 answer
  • Which of these practices should you follow while creating your resume?
    13·2 answers
  • What factors should you consider when buying a hard drive?
    8·1 answer
  • What is the difference page break and column break ​
    7·2 answers
  • Making sure that your business has something special and distinct to offer is known as?
    12·1 answer
  • C++ code pls write the code
    12·1 answer
  • What section of the outline is represented by "A. Africa?"
    11·2 answers
  • Create two Lists, one is ArrayList and the other one is LinkedList and fill it using 10 state names (e.g., Texas). Sort the list
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!