How to use scala Map size method

0 votes
How to use scala Map size() method?
Nov 17, 2020 in Big Data Hadoop by anonymous
• 8,880 points
99 views

1 answer to this question.

0 votes

The size() is utilized to find the number of key-value pairs in the stated map.

Method Definition: def size: Int

Return Type: It returns the number of elements in the map.

// Scala program of size()

// method

  

// Creating object

object GfG

{ 

  

    // Main method

    def main(args:Array[String])

    {

      

        // Creating a map

        val m1 = Map(3 -> "geeta", 1 -> "for", 2 -> "cs")

          

        // Applying size method

        val result = m1.size

          

        // Displays output

        println(result)

      

    }

}
answered Nov 17, 2020 by Gitika
• 65,930 points

Related Questions In Big Data Hadoop

0 votes
1 answer

How to use custom FileInputFormat in MapReduce?

You have to override isSplitable method. ...READ MORE

answered Apr 10, 2018 in Big Data Hadoop by Shubham
• 13,480 points
450 views
0 votes
1 answer

How can I use my host machine’s web browser to check my HDFS services running in the VM?

The sole purpose of the virtual machine ...READ MORE

answered Apr 18, 2018 in Big Data Hadoop by Shubham
• 13,480 points
499 views
0 votes
1 answer

How to set the number of Map & Reduce tasks?

The map tasks created for a job ...READ MORE

answered Apr 18, 2018 in Big Data Hadoop by Shubham
• 13,480 points
385 views
0 votes
1 answer

How to groupBy/count then filter on count in Scala

I think the exception is caused because ...READ MORE

answered Apr 19, 2018 in Big Data Hadoop by kurt_cobain
• 9,390 points
23,171 views
0 votes
1 answer

How to start working with scala?

Scala can be installed on any UNIX ...READ MORE

answered Nov 16, 2020 in Big Data Hadoop by Gitika
• 65,930 points
75 views
0 votes
1 answer

How to execute scala programming?

We can execute a Scala program in ...READ MORE

answered Nov 16, 2020 in Big Data Hadoop by Gitika
• 65,930 points
118 views
0 votes
1 answer

How to write a Scala program in script mode?

Open notepad and add the following code ...READ MORE

answered Nov 16, 2020 in Big Data Hadoop by Gitika
• 65,930 points
148 views
0 votes
1 answer

How to import scala packages?

Scala packages can be imported so that ...READ MORE

answered Nov 16, 2020 in Big Data Hadoop by Gitika
• 65,930 points
79 views
0 votes
1 answer

How to use scala map as mutable map?

By default, Scala uses an immutable Map. ...READ MORE

answered Nov 17, 2020 in Big Data Hadoop by Gitika
• 65,930 points
134 views
0 votes
1 answer

How to use Hbase shell in a bash script?

Hello, To write scripts with HBase shell it includes non-interactive mode, ...READ MORE

answered May 29, 2019 in Big Data Hadoop by Gitika
• 65,930 points
1,305 views