toString convert to long
Java
long number = 45;
System.out.println(Long.toBinaryString(number)); //101101
System.out.println(Long.toOctalString(number)); //55
System.out.println(Long.toHexString(number)); //2d
System.out.println(Long.toString(number, 5)); //140
long l = 12345L;
String str = new StringBuilder().append(l).toString();
long l = 369L;
String s = String.format("%d", l);
long l = 12345L;
String str = String.valueOf(l); // str is '12345'
long l = 12345L;
String str = Long.toString(l);
System.out.println(str); //prints '12345'
package com.journaldev.string;
import java.text.DecimalFormat;
public class JavaLongToString {
@SuppressWarnings("deprecation")
public static void main(String[] args) {
long l = 12345L;
String str = Long.toString(l);
System.out.println(str);
str = String.valueOf(l);
System.out.println(str);
// deprecated from Java 9, use valueOf for better performance
str = new Long(l).toString();
System.out.println(str);
str = String.format("%d", l);
System.out.println(str);
str = l + "";
System.out.println(str);
str = DecimalFormat.getNumberInstance().format(l);
System.out.println(str);
str = new DecimalFormat("#").format(l);
System.out.println(str);
str = new StringBuilder().append(l).toString();
System.out.println(str);
}
}
long l = 12345L;
String str = DecimalFormat.getNumberInstance().format(l);
System.out.println(str); //str is '12,345'
//if you don't want formatting
str = new DecimalFormat("#").format(l);
System.out.println(str); //str is '12345'
long l = 12345L;
//deprecated from Java 9, use valueOf for better performance
String str = new Long(l).toString(); // str is '12345'
long l = 0x11L;
String str = Long.toString(l);
System.out.println(str); //prints '17'
l = 011L;
str = Long.toString(l);
System.out.println(str); //prints '9'
Also in Java:
- Title
- java how to show an array
- Category
- Java
- Title
- java random between two strings
- Category
- Java
- Title
- java d'intervalle de resultat
- Category
- Java
- Title
- java nextpermutation
- Category
- Java
- Title
- how to print an array in java
- Category
- Java
- Title
- java observable
- Category
- Java
- Title
- java best way to concatenate strings
- Category
- Java
- Title
- how to calculate exponential in java
- Category
- Java
- Title
- generate objects with for loop java
- Category
- Java
- Title
- online money transfer andhra bank
- Category
- Java
- Title
- java read from file
- Category
- Java
- Title
- java random boolean
- Category
- Java
- Title
- java get environment variables
- Category
- Java
- Title
- capacitor-android. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project
- Category
- Java
- Title
- binary search tree insert java
- Category
- Java
- Title
- reverse array in java
- Category
- Java
- Title
- java exponencial
- Category
- Java
- Title
- java observable to observer
- Category
- Java
- Title
- count number of matches in two strings java
- Category
- Java
- Title
- Write a JAVA method that expands a given binomial (ax + by)n, where integers a, b, n are user inputs. For example, if a = 2, b = -12, n = 4 are entered the method should print or return
- Category
- Java
- Title
- how to separate no and text in java
- Category
- Java
- Title
- java newinstance alternative
- Category
- Java
- Title
- java program to display characters from a to z using loop
- Category
- Java
- Title
- simple calculator program in java
- Category
- Java
- Title
- how to add multiple filter condition in Java stream filter chain
- Category
- Java
- Title
- inheritance in java
- Category
- Java
- Title
- java file class
- Category
- Java
- Title
- how to send http post create request using curl command
- Category
- Java
- Title
- convert array of int to arraylist java
- Category
- Java
- Title
- java how to compare strings
- Category
- Java
- Title
- how to compare two maps in java
- Category
- Java
- Title
- java 8 validate based on pair of strings
- Category
- Java
- Title
- array of objects in java
- Category
- Java
- Title
- Java system load from resources
- Category
- Java
- Title
- java letter alphabet index
- Category
- Java
- Title
- java read file bufferedreader
- Category
- Java
- Title
- android dynamically create layer-list with item and shape site:stackoverflow.com
- Category
- Java
- Title
- java public private key encryption
- Category
- Java
- Title
- java function for power
- Category
- Java
- Title
- contains example in java
- Category
- Java
- Title
- if statement java
- Category
- Java
- Title
- java question mark operator
- Category
- Java
- Title
- how to make a pre set list java
- Category
- Java
- Title
- discord jda remove @everyone from channel
- Category
- Java
- Title
- android studio clear views of layout
- Category
- Java
- Title
- multiplication program java
- Category
- Java
- Title
- string equality in java
- Category
- Java
- Title
- java list to set
- Category
- Java
- Title
- como detener un void java
- Category
- Java
- Title
- change fab image programatically
- Category
- Java
- Title
- iterate trough linked list java
- Category
- Java
- Title
- how to fill a 2d array in java
- Category
- Java
- Title
- java hash password
- Category
- Java
- Title
- how to check the end of a string java
- Category
- Java
- Title
- java cast duration to long
- Category
- Java
- Title
- method overloading
- Category
- Java
- Title
- java add a list to a list
- Category
- Java
- Title
- Category
- Java
- Title
- java read lines from file
- Category
- Java
- Title
- parse string to int java
- Category
- Java
- Title
- mutable string in java
- Category
- Java
- Title
- height constraint layout guideline
- Category
- Java
- Title
- java compareto
- Category
- Java
- Title
- java fullscreen jframe
- Category
- Java
- Title
- java pass array as method parameter
- Category
- Java
- Title
- scan a string using scanner class in java
- Category
- Java
- Title
- nth prime number java
- Category
- Java
- Title
- java vs javascript
- Category
- Java
- Title
- foreach not applicable to type - binary tree sort
- Category
- Java
- Title
- java constructor genertic
- Category
- Java
- Title
- [ERROR] Error executing Maven. java.io.FileNotFoundException: The specified user settings file does not exist: /usr/lib/jvm/java-1.8.0-openjdk-amd64
- Category
- Java
- Title
- even or odd in java
- Category
- Java
- Title
- Java nested array hashcode
- Category
- Java
- Title
- index of an array procesing
- Category
- Java
- Title
- java int to int array
- Category
- Java
- Title
- how to access private vairable in java method
- Category
- Java
- Title
- what is a float java
- Category
- Java
- Title
- loop through array java
- Category
- Java
- Title
- java get location of jar file
- Category
- Java
- Title
- java int passed by reference
- Category
- Java
- Title
- j
- Category
- Java
- Title
- spigot custom join message
- Category
- Java
- Title
- Could not resolve project :app
- Category
- Java
- Title
- detect tv remote keys andoid studio
- Category
- Java
- Title
- log4j print stacktrace
- Category
- Java
- Title
- .length array java
- Category
- Java
- Title
- check java version cmd
- Category
- Java
- Title
- how to convert a jsonobject to a dbobject
- Category
- Java
- Title
- difference between compile and execute in java
- Category
- Java
- Title
- how to delete character in string java
- Category
- Java
- Title
- creating the functional interface in java
- Category
- Java
- Title
- java replace all html tags
- Category
- Java
- Title
- java boolean even number
- Category
- Java
- Title
- hide element selenium
- Category
- Java
- Title
- java ternary operator
- Category
- Java
- Title
- do statement java
- Category
- Java
- Title
- java switch display panel
- Category
- Java
- Title
- delete object java
- Category
- Java
- Title
- write a java program to check whether given number is binary or not
- Category
- Java
- Title
- LocalRegistry java rebind() java8
- Category
- Java