Sunday, 26 May 2019

Java: Convert long to hexa string


'Long.toHexString' method converts a long to hexa string.

Example
long number = 255l;
String hexaString = Long.toHexString(number);

App.java
package com.sample.app;

public class App {

 public static void main(String args[]) {
  long number = 255l;
  String hexaString = Long.toHexString(number);

  System.out.println("number : " + number);
  System.out.println("hexaString : " + hexaString);

 }

}

Output
number : 255
hexaString : ff


You may like


No comments:

Post a Comment