是这个意思么?
public class $ {
public static void main(String[] args) {
double d = Math.random();
System.out.println(d + "的长度是:" + String.valueOf(d).length());
}
}
先转化成字符串,再求字符串的长度!
Double b =11.12;
String str=b+"";
System.out.println("changdu:"+(str.length()-1));