tostring convert to long

Solutions on MaxInterview for tostring convert to long by the best coders in the world

showing results for - "tostring convert to long"
Juliette
28 Jan 2019
1
2long l = 12345L;
3String str = Long.toString(l);
4System.out.println(str); //prints '12345'
5
Valery
15 Jan 2021
1
2long l = 12345L;
3String str = new StringBuilder().append(l).toString();
4
Coralie
28 Apr 2018
1
2long l = 0x11L;
3String str = Long.toString(l);
4System.out.println(str); //prints '17'
5l = 011L;
6str = Long.toString(l);
7System.out.println(str); //prints '9'
8
Trace
12 Jan 2017
1
2package com.journaldev.string;
3
4import java.text.DecimalFormat;
5
6public class JavaLongToString {
7
8	@SuppressWarnings("deprecation")
9	public static void main(String[] args) {
10		long l = 12345L;
11		String str = Long.toString(l);
12		System.out.println(str);
13
14		str = String.valueOf(l);
15		System.out.println(str);
16
17		// deprecated from Java 9, use valueOf for better performance
18		str = new Long(l).toString();
19		System.out.println(str);
20
21		str = String.format("%d", l);
22		System.out.println(str);
23
24		str = l + "";
25		System.out.println(str);
26
27		str = DecimalFormat.getNumberInstance().format(l);
28		System.out.println(str);
29
30		str = new DecimalFormat("#").format(l);
31		System.out.println(str);
32
33		str = new StringBuilder().append(l).toString();
34		System.out.println(str);
35	}
36}
37
Claudio
23 Jun 2016
1
2long l = 12345L;
3//deprecated from Java 9, use valueOf for better performance
4String str = new Long(l).toString(); // str is '12345'
5
Esteban
03 Nov 2018
1
2long l = 369L;
3String s = String.format("%d", l);
4
Francesca
18 Jun 2017
1
2long l = 12345L;
3String str = String.valueOf(l); // str is '12345'
4
Kieran
14 Jul 2020
1
2long number = 45;
3System.out.println(Long.toBinaryString(number)); //101101
4System.out.println(Long.toOctalString(number)); //55
5System.out.println(Long.toHexString(number)); //2d
6System.out.println(Long.toString(number, 5)); //140
7
Daragh
18 May 2020
1
2long l = 12345L;
3String str = DecimalFormat.getNumberInstance().format(l);
4System.out.println(str); //str is '12,345'
5//if you don't want formatting
6str = new DecimalFormat("#").format(l);
7System.out.println(str); //str is '12345'
8
queries leading to this page
long to string javaconvert long to stringstring to big decimaljava how to parse long to stringconverting a long to string and storing in the same variablejava from long to stringlong to stringjava cast long to stronglong to string in jacacreate a method that converts long to stringlong long to stringconversion of long to stringlong to string cast javacasting long to string javacomment convertir de long c3 a0 stringlong tostring javalong tostring 28 29cast long to stringconverting long to string in javajava 8 long to stringandroid format long to stringcannot convert long to string javajava long to stringhow to convert long to string javaandroid convert long to stringhow to convert long so string javahow to convert a long to a string in javaconvert long to string in javaadd long to string formatlong sostring javastring to long convertlongstream to sting in javaconert a long to string in javahow to convert from long to string in javahow to convert long long to string in javaconvert long to string javagetstring from long javajava change long to stringconverting a long to string in javaprint long as a stringhow to cast a long number to string javalong to strong in javahow to format a long string in javajava parse long as stringhow to make a long into a stringchange long to stringlong to string in javalong to string conversionjava cast long to stringlong convert string javalong string javajava long to strngbest way to turn a long into string in javahow to convert long to string in javahow to change the long value to string in javalong to string androidlong stringconvert long to string android studiochange long to string javajava long stringlong to string in androidjava convert long to stringcast long to string javahow to convert long into stringhow to convert long to stringlong to string javajava how convert long to stringconvert long to string in javejava long to stringparsing long to string in javatypecast long to string in javajavascript date to longjava parse long to stringconert long to stringlong convert to string javalong tostringjava long into stringconver long to string javaandroid studio convert long to stringchange form long to string spring boothow to convert long into string in javajava turn long into stringjava long tostringconvert long to string androidjava long t stringreturn long as stringde long a string javahow to convert long to string in javajava compare long to stringandroid cast long to stringtostring convert to long