

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert Int to Hex String in Kotlin?
Kotlin is statistically typed language and it is built on JVM. Kotlin is cent percent comparable with Java. Hence, some of the Java functions can be used in Kotlin as well.
In this article, we will take an example to demonstrate how we can use a Java class function convert an Int in Kotlin to its correponding Hex String.
Example – Converting Int to Hex String in Kotlin
In this example, we will use the Java class function toHexString().
import java.lang.* fun main(args: Array<String>) { val hexString = java.lang.Integer.toHexString(-66) println("Hex String for negative Number: " +hexString) val positiveNumber = java.lang.Integer.toHexString(166) println("Hex String for positive Number: " +positiveNumber) }
Output
On execution, it will produce the following output −
Hex String for negative Number: ffffffbe Hex String for positive Number: a6
- Related Questions & Answers
- How to convert hex string into int in Python?
- How to Convert Hex String to Hex Number in C#?
- How to convert int to String in java?
- How to convert int to string in Python?
- Convert Integer to Hex String in Java
- Convert hex string to number in MySQL?
- Convert String to Java int
- Convert int to String in Java
- How to convert hex string to byte Array in Java?
- Python program to convert hex string to decimal
- How to convert an int to string in C++?
- Convert byte Array to Hex String in Java
- Convert Hex String to byte Array in Java
- How to convert String to Long in Kotlin?
- How to convert a byte array to hex string in Java?
Advertisements