如何通过两个地图的值比较两个地图并为每个键打印最大值

void displayFeedback(){

    Map<String, Integer> maths = new HashMap<String, Integer>();

    maths.put("Nirmala", 70);

    maths.put("Subaksha", 80);

    Map<String, Integer> english = new HashMap<String, Integer>();

    english.put("Nirmala", 75);

    english.put("Subaksha", 60);

    //same staffs taking two different subjects maths and english 

    //values taken as feedback for each subject

    // i need to compare both subject feedback and print only max as o/p

    System.out.println(maths);

    System.out.println(maths.entrySet());

    //maths.

    //maths.entrySet();

    //Collections.max(coll, comp)

    Map<String, Integer> top = new HashMap<String, Integer>();

    System.out.println(maths.size());

    for (Map.Entry<String, Integer> math: maths.entrySet()){

        for (Map.Entry<String, Integer> eng: english.entrySet()){   

        //for(int i = 0;i<maths.size();i++){

            //math.comparingByValue()

            System.out.println(math.getValue()+" "+eng.getValue());

            //Collections.max(math.getValue(), eng.getValue());

        if(math.getValue() <= eng.getValue()){

            //System.out.println(" math <= eng");


        }else

        {

            //System.out.println("math > eng");

        }

在这两种地图中,教师是共同的,他们既处理数学又涉及英语科目,并且他们在每个下层的反馈都作为这两种科目的值


我需要比较并找到最大反馈值,并仅将最大值打印给每位老师.... t老师在两个图中都是通用键


眼眸繁星
浏览 135回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java