- public class Shuzi {
- public static void main(String[] args){
- float a=0.012f;
- //把数字转化为字符串
- String s1=String.valueOf(a);
- //把字符串转化为字符数组
- char[] s2=s1.toCharArray();
- //boolean b=str.contains("3");
- if(s2[0]=='0'){
- System.out.println("首位数字是0");
- }
- else
- {
- System.out.println("首位数字不是0");
- }
-
- }
-
- }
复制代码 做出来了:
|