1. 首页>百科大全 > 百科

java怎么把数字变成字符串

作者:刘龙林
2020-04-21
百科

1.java中怎么将数字转换成字符串

public class welcome {

public static void main(String[] args){

// Scanner input=new Scanner(System.in);

int count=1;

for(int i=33;i<=126;i++)

{

char c=(char)i;

System.out.print(c+"t");

count++;

if(count%10==0)

System.out.println();

}

}

}

2.JAVA如何把数字1

放到一个数组最简单了,根据数字去索引.import java.util.Scanner;public class Du3 { public static void main(String[] args) { String[] numsAry = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; Scanner scanner = new Scanner(System.in); System.out.print("Please input a number between 1 and 9: "); int num = scanner.nextInt(); System.out.println(num + " to corresponding string is: " + numsAry[num]); }}----------------Please input a number between 1 and 9: 55 to corresponding string is: five。

3.java数字转换字符串

public class Test

{

public static void main(String[] args)

{

String str = "1 2 3 4 5567834190";

String tmp = "0123456789零一二三四五六七八九";

for(int i = 0; i < tmp.length() / 2; i++)

{

str = str.replaceAll(tmp.charAt(i) + "", tmp.charAt(i + 10) + "");

}

System.out.println(str);

}

}

4.java 数字转字符串

各种数字类型转换成字符串型:

String s = String.valueOf( value); // 其中 value 为任意一种数字类型。

字符串型转换成各种数字类型:

String s = "169";

byte b = Byte.parseByte( s );

short t = Short.parseShort( s );

int i = Integer.parseInt( s );

long l = Long.parseLong( s );

Float f = Float.parseFloat( s );

Double d = Double.parseDouble( s );

数字类型与数字类对象之间的转换:

byte b = 169;

Byte bo = new Byte( b );

b = bo.bytevalue();

short t = 169;

Short to = new Short( t );

t = to.shortValue();

int i = 169;

b = bo.bytevalue();

short t = 169;

Short to = new Short( t );

t = to.shortValue();

int i = 169;

Integer io = new Integer( i );

i = io.intValue();

long l = 169;

Long lo = new Long( l );

l = lo.longValue();

float f = 169f;

Float fo = new Float( f );

f = fo.floatValue();

double d = 169f;

Double dObj = new Double( d );

d = dObj.doublevalue();

5.java中 将数字转换成字符

public class welcome { public static void main(String[] args){ // Scanner input=new Scanner(System.in); int count=1; for(int i=33;i<=126;i++) { char c=(char)i; System.out.print(c+"t"); count++; if(count%10==0) System.out.println(); } }}。

推荐阅读
  • 努比亚z9max手机音乐效验

    该机拥有HIFI级音乐芯片,音乐效果不凡。具体体现在:1.音量调节,正常听音乐中高低音都是一个音量,而杜比音效能动态扩大某个音量。比如放打鼓声,杜比会及时提高低音加强鼓声。2.加强音域,杜比音效有开阔、集中、…

    百科 2024-09-20
  • 是atChristmas还是inChristmas

    此处该用“on”。在圣诞节正确表达应为 “on Christmas ”。有具体日期的,比如知道几月几日的都用“on” ;不知道日期,但知道年份和月份的用“in” ,知道具体时间,比如几点几分用“at”。…

    百科 2024-09-20
  • 个体工商户应交纳什么税

    纳税标准根据国家税务总局《个体工商户定期定额征收管理办法》文件精神 ,定期定额征收方式适用的税种及税率如下:1、根据《中华人民共和国增值税暂行条例》规定,自2009年1月1日起,小规模纳税人增值税征收率为3%…

    百科 2024-09-20
  • 材料成本差异率为负数是什么意思

    材料成本差异额,是指材料的实际成本和计划成本之间的差额。差异率负数表示节约差异,即实际成本比计划成本小。正数表示超支差异,即实际成本比计划成本大。…

    百科 2024-09-20
  • 塞翁失马焉知非福是什么意思

    比喻一时虽然受到损失,反而因此能得到好处。也指坏事在一定条件下可变为好事,反之亦然。形容人的心态,一定要乐观向上,任何事情都有二面性,不好的一面,有可能向好的一面转化。塞翁失马,焉知非福出自《 淮南子…

    百科 2024-09-20