Scala Int toBinaryString() method with example
Last Updated :
30 Jan, 2020
The toBinaryString() method is utilized to return the binary form of the specified integer value.
Method Definition: def toBinaryString: String
Return Type: It returns the binary form of the specified integer value.
Example #1:
object GfG
{
def main(args : Array[String])
{
val result = ( 5 ).toBinaryString
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val result = ( 15 ).toBinaryString
println(result)
}
}
|
Share your thoughts in the comments
Please Login to comment...