获取码值和进制转换


  • 程序由来

       本人发现计算机中的计算器木有将十进制小数转二进制的功能,后来发现一些网站将十进制负数转成二进制只是求出正数的二进制,然后前面加“-”,这种表示不是真正的负数二进制。于是有点较真儿的本人写了一个可以转十进制正数、正数加小数、小数、负数、负数加小数为二进制、八进制、十六进制;二进制转成八进制、十进制、十六进制;八进制(正/负)转成二进制、十进制、十六进制,十六进制(正/负)转二进制、八进制、十六进制。供大家学习参考。介于理解代码,代码中运用到了纯拼音。虽然是拼音,但符合代码编写格式。介于个人知识有限,代码如有需要修改和改进的地方,敬请大家评教指正,共同学习。


  • 实现功能:

  1. 获取字符的码值,包括中文。

  2. 进制转换包括:十进制(整数/小数/负数)转成二进制、八进制、十六进制;二进制转成八进制、十进制、十六进制;八进制(正/负)转成二进制、十进制、十六进制;十六进制(正/负)转二进制、八进制、十进制。

  3. 供需要学习Java基础的朋友参考学习。


  • 代码:

  1.   代码语言:Java

  2.   包:

             包名.png

  3. 源码:


  • 主方法(main)类:主要是表现用户功能选择界面

package com.main.lt;import java.util.Scanner;import com.jinzhizhuanhuan.lt.JinZhiZhuanHuan;import com.mazhi.lt.HuoQuMaZhi;import com.menus.lt.Menus;/** *  * @author LiuTong * @version V1.2 *  *      */public class MainApp {    public static void main(String[] args) {//主方法        //创建菜单类对象        Menus menus = new Menus();        //创建获取码值方法对象        HuoQuMaZhi hQMZ = new HuoQuMaZhi();        //创建进制转换对象        JinZhiZhuanHuan jinZhiZhuanHuan = new JinZhiZhuanHuan();        //创建键盘录入对象        Scanner sc = new Scanner(System.in);        //使用while循环        //定义断点,用于退出while循环        boolean zhuBL = true;        while(zhuBL){            //使用菜单对象调用主菜单            menus.mainMenus();            //键盘录入,使用switch语句判断,做相应操作(case)            switch(sc.nextLine()){            case "1"://获取码值                hQMZ.huoQuMaZhi();//使用获取码值对象调用获取码值方法                break;            case "2"://进制转换                jinZhiZhuanHuan.jinZhiZhuanHuan();//使用进制转换对象调用进制转换方法                break;            case "3":                zhuBL = false;//断点                break;            case "":                menus.shiKongMenu();//为空菜单                break;                default:                    menus.shuRuCuoWuMenu();//输入错误菜单                    break;            }        }    }}

  • 菜单类:

package com.menus.lt;/** *  * @author LiuTong * @version V1.2 * */public class Menus {    //空构造    public Menus(){            }        //成员方法    //主菜单    public void mainMenus(){        System.out.println("-------------------------主菜单---------------------------");        System.out.println("1、查询码值\t2、进制转换\t3、退出");        System.out.print("请输入您的操作:");    }    //------------------------------------------字节码------------------------------------    //字节码菜单    public void huoQuMaZhiMenus(){        System.out.println("-------------------------字节码-------------------------");        System.out.print("请输入内容(中文、英语、符号):");    }        //------------------------------------------进制转换------------------------------------    public void jinZhiZhuanHuanMenus(){        System.out.println("-------------------------进制转换-------------------------");        System.out.println("1、二进制转成其他进制\t2、八进制转成其他进制\t3、十进制转成其他进制\t4、十六进制转成其他进制\n5、返回");        System.out.print("请输入您的操作:");    }        //------------------------------------------十进制转其他进制------------------------------------    public void shiZhuanQiTaMenus(){        System.out.println("------------------十进制转其他进制------------------");        System.out.println("1、转成二进制\t2、转成八进制\t3、转成十六进制\n4、返回");        System.out.print("请输入您的操作:");    }    public void shiZhuanErMenu(){        System.out.println("------------------十进制转成二进制------------------");        System.out.print("请输入数据(整数(正负)、小数):");    }    public void shiZhuanBaMenu(){        System.out.println("------------------十进制转成八进制------------------");        System.out.print("请输入数据(整数(正负)、小数):");    }    public void shiZhuanShiLiuMenu(){        System.out.println("------------------十进制转成十六进制------------------");        System.out.print("请输入数据(整数(正负)、小数):");    }    //-----------------------------------------------------------------------------------------    //------------------------------------------二进制转其他进制------------------------------------    public void erZhaunQiTaMenus(){        System.out.println("------------------二进制转其他进制------------------");        System.out.println("1、转成八进制\t2、转成十进制\t3、转成十六进制\n4、返回");        System.out.print("请输入您的操作:");    }    public void erZhuanBaMenu(){        System.out.println("------------------二进制转成八进制------------------");        System.out.print("请输入数据(1/0):");    }    public void erZhuanShiMenu(){        System.out.println("------------------二进制转成十进制------------------");        System.out.print("请输入数据(1/0):");    }    public void erZhuanShiLiuMenu(){        System.out.println("------------------二进制转成十六进制------------------");        System.out.print("请输入数据(1/0):");    }    //-----------------------------------------------------------------------------------------    //------------------------------------------八进制转其他进制------------------------------------    public void baZhuanQiTaMenus(){        System.out.println("------------------八进制转其他进制------------------");        System.out.println("1、转成二进制\t2、转成十进制\t3、转成十六进制\n4、返回");        System.out.print("请输入您的操作:");    }    public void baZhuanErMenu(){        System.out.println("------------------八进制转成二进制------------------");        System.out.print("请输入数据([0-7]+):");    }    public void baZhuanShiMenu(){        System.out.println("------------------八进制转成十进制------------------");        System.out.print("请输入数据([0-7]+):");    }    public void baZhuanShiLiuMenu(){        System.out.println("------------------八进制转成十六进制------------------");        System.out.print("请输入数据([0-7]+):");    }    //-----------------------------------------------------------------------------------------    //------------------------------------------十六进制转其他进制------------------------------------    public void shiLiuZhuanQiTaMenus(){        System.out.println("------------------十六进制转其他进制------------------");        System.out.println("1、转成二进制\t2、转成八进制\t3、转成十进制\n4、返回");        System.out.print("请输入您的操作:");    }    public void shiLiuZhuanErMenu(){        System.out.println("------------------十六进制转成二进制------------------");        System.out.print("请输入数据:");    }    public void shiLiuZhuanBaMenu(){        System.out.println("------------------十六进制转成十进制------------------");        System.out.print("请输入数据:");    }    public void shiLiuZhuanShiMenu(){        System.out.println("------------------十六进制转成八进制------------------");        System.out.print("请输入数据:");    }    //---------------------------------------提示菜单--------------------------------------------------    //输入为空提示菜单    public void shiKongMenu(){        System.out.println("输入不能为空,请重新输入!");    }    //输入错误提示菜单    public void shuRuCuoWuMenu(){        System.out.println("输入错误,请重新输入!");    }    //是否继续输入提示    public void shiFouJiXuMenu(){        System.out.println("是否继续(Y/N)?");    }    //是否是数字    public void buShiShuZiMenu(){        System.out.println("您的输入含有不是数字的内容!");    }    }

  • 获取码值类:

package com.mazhi.lt;import java.util.Scanner;import com.jinzhizhuanhuan.lt.JinZhiZhuanHuan;import com.main.lt.MainApp;import com.menus.lt.Menus;/** *  * @author LiuTong * @version V1.2 * */public class HuoQuMaZhi {    //空构造    public HuoQuMaZhi(){}    //创建菜单对象    Menus menus = new Menus();    //定义用户选择方法    public void huoQuMaZhi(){        //定义断点        boolean huoQuMaZhiBL = true;        while(huoQuMaZhiBL){            menus.huoQuMaZhiMenus();//使用菜单对象调用码值菜单            String huoQuMaZhiStr =  new Scanner(System.in).nextLine();            if("".equals(huoQuMaZhiStr)){                menus.buShiShuZiMenu();            }else{                byte[] b = huoQuMaZhiStr.getBytes();                System.out.println(new String(b)+":"+"的字节码值和二进制表示为:");                for(int c : b){                    System.out.println("字节码值:"+c+"\t"+"字节码值二进制表示:"+Integer.toBinaryString(c));                }                System.out.println("------------------------------------------------------");                //是否继续                if(!new JinZhiZhuanHuan().sel()){                    huoQuMaZhiBL = false;                }            }                    }    }}

  • 进制转换类:

package com.jinzhizhuanhuan.lt;import java.util.Scanner;import com.main.lt.MainApp;import com.menus.lt.Menus;/** *  * @author LiuTong * @version V1.2 * */public class JinZhiZhuanHuan {//进制转换菜单    //空构造    public JinZhiZhuanHuan(){}        //进制转换选择方法    public void jinZhiZhuanHuan(){        //创建菜单对象        Menus menus = new Menus();        //定义断点        boolean jinZhiZhuanHuanBL = true;        //while循环        while(jinZhiZhuanHuanBL){            //使用菜单对象调用进制转换菜单            menus.jinZhiZhuanHuanMenus();            //swtich语句,选择现有的操作            switch(new Scanner(System.in).nextLine()){            case "1":                erZhuanQiTa();                break;            case "2":                baZhuanQiTa();                break;            case "3":                shiZhuanQiTa();                break;            case "4":                shiLiuZhuanQiTa();                break;            case "5":                jinZhiZhuanHuanBL = false;                break;            case "":                menus.shiKongMenu();                break;                default:                    menus.shuRuCuoWuMenu();                    break;            }        }        //new MainApp();    }    //----------------------------------------二进制转其他进制-----------------------------------------    //二进制转其他进制    public void erZhuanQiTa(){        //定义断点        boolean  erZhuanQiTaBL = true;        Menus menus = new Menus();//创建菜单对象        //while循环        while(erZhuanQiTaBL){            menus.erZhaunQiTaMenus();            switch(new Scanner(System.in).nextLine()){            case "1":                erZhuanBa();                break;            case "2":                erZhuanShi();                break;            case "3":                erZhuanShiLiu();                break;            case "4":                erZhuanQiTaBL = false;                break;            case "":                menus.shiKongMenu();                break;                default:                    menus.shuRuCuoWuMenu();                    break;            }        }    }    //----------------------------------二进制转八进制---------------------------------------------    public void erZhuanBa(){        //定义断点        boolean erZhuanBaBL = true;        while(erZhuanBaBL){            new Menus().erZhuanBaMenu();;            String sel = new Scanner(System.in).nextLine();            String shi = "";            if(shiErJinZhi(sel)){                System.out.println("八进制:"+Integer.toOctalString(Integer.valueOf(Integer.valueOf(sel,2).toString())));                //判断是否继续                if(!sel()){                    erZhuanBaBL = false;                }            }else{                new Menus().shuRuCuoWuMenu();            }        }    }    //----------------------------------二进制转十进制------------------------------------------------    public void erZhuanShi(){        //定义断点        boolean erZhuanShiBL = true;        while(erZhuanShiBL){            new Menus().erZhuanShiMenu();            String sel = new Scanner(System.in).nextLine();            if(shiErJinZhi(sel)){                System.out.println("十进制:"+Integer.valueOf(sel,2).toString());                //判断是否继续                if(!sel()){                    erZhuanShiBL = false;                }            }else{                new Menus().shuRuCuoWuMenu();            }        }    }    //----------------------------------二进制转十六进制------------------------------------------------    public void erZhuanShiLiu(){        //定义断点        boolean erZhuanShiLiuBL = true;        while(erZhuanShiLiuBL){            new Menus().erZhuanShiLiuMenu();            String sel = new Scanner(System.in).nextLine();            if(shiErJinZhi(sel)){                System.out.println("十六进制:"+Integer.toHexString(Integer.valueOf(Integer.valueOf(sel,2).toString())));                //判断是否继续                if(!sel()){                    erZhuanShiLiuBL = false;                }            }else{                new Menus().shuRuCuoWuMenu();            }        }            }        //-------------------------------------------------------------------------------------------    //----------------------------------------------八进制转其他进制-----------------------------------    public void baZhuanQiTa(){        //定义断点        boolean baZhuanQiTaBL = true;        Menus menus = new Menus();//创建菜单对象        //while循环        while(baZhuanQiTaBL){            menus.baZhuanQiTaMenus();            switch(new Scanner(System.in).nextLine()){            case "1":                baZhuanEr();                break;            case "2":                baZhuanShi();                break;            case "3":                baZhuanShiLiu();                break;            case "4":                baZhuanQiTaBL = false;                break;            case "":                menus.shiKongMenu();                break;                default:                    menus.shuRuCuoWuMenu();                    break;            }        }    }    //------------------------------------------------八转二---------------------------------------    public void baZhuanEr(){        //定义断点        boolean baZhuanErBL = true;        while(baZhuanErBL){            new Menus().baZhuanErMenu();            String sel = new Scanner(System.in).nextLine();            if(shiBaJinZhi(sel)){                System.out.println("二进制:"+Integer.toBinaryString(Integer.valueOf(Integer.valueOf(sel,8).toString())));                //判断是否继续                if(!sel()){                    baZhuanErBL = false;                }            }else{                new Menus().shuRuCuoWuMenu();            }        }    }    //------------------------------------------------八转十---------------------------------------    public void baZhuanShi(){        //定义断点        boolean baZhuanShiBL = true;        while(baZhuanShiBL){            new Menus().baZhuanShiMenu();            String sel = new Scanner(System.in).nextLine();            if(shiBaJinZhi(sel)){                System.out.println("十进制:"+Integer.valueOf(Integer.valueOf(sel,8).toString()));                //判断是否继续                if(!sel()){                    baZhuanShiBL = false;                }            }else{                new Menus().shuRuCuoWuMenu();            }        }    }    //-------------------------------------------------------------------------------------------    //------------------------------------------------八转十六---------------------------------------    public void baZhuanShiLiu(){        //定义断点        boolean baZhuanShiLiuBL = true;        while(baZhuanShiLiuBL){            new Menus().baZhuanShiLiuMenu();;            String sel = new Scanner(System.in).nextLine();            if(shiBaJinZhi(sel)){                System.out.println("二进制:"+Integer.toHexString(Integer.valueOf(Integer.valueOf(sel,8).toString())));                //判断是否继续                if(!sel()){                    baZhuanShiLiuBL = false;                }            }else{                new Menus().shuRuCuoWuMenu();            }        }    }    //-------------------------------------------------------------------------------------------    //----------------------------------------------十进制转其他进制-----------------------------------    //十转其他    public void shiZhuanQiTa(){        //创建菜单目录        Menus menus = new Menus();        //定义断点        boolean shiZhuanQiTaBL = true;        while(shiZhuanQiTaBL){            menus.shiZhuanQiTaMenus();//调用十转其他进制菜单            //switch语句            switch(new Scanner(System.in).nextLine()){            case "1":                shiZhuanEr();                break;            case "2":                shiZhuanBa();                break;            case "3":                shiZhuanShiLiu();                break;            case "4":                shiZhuanQiTaBL = false;                break;            case "":                menus.shiKongMenu();                break;                default:                    menus.shuRuCuoWuMenu();                    break;            }        }    }    //-------------------------十进制转成二进制---------------------------    public void shiZhuanEr(){        //定义断点        boolean shiZhuanErBL = true;        while(shiZhuanErBL){            new Menus().shiZhuanErMenu();            String str = new Scanner(System.in).nextLine();            if(shuZi(str)){                String regex2 = "-?[0-9]+";                boolean n = str.matches(regex2);                //整数部分的二进制                String l1 = "";                if(n){                    System.out.println("二进制:"+Integer.toBinaryString(Integer.valueOf(str)));                    //判断是否继续                    if(!sel()){                        shiZhuanErBL = false;                    }                }else if(catc(str)){                    String [] strs = str.split("\\.");                    System.out.println("二进制"+Integer.toBinaryString(Integer.valueOf(strs[0])));                    //判断是否继续                    if(!sel()){                        shiZhuanErBL = false;                    }                }else{                    //分割字符串,得到整数部分和小数部分                    String [] strs = str.split("\\.");                    if(strs[1]==""){                        System.out.println("二进制:"+Integer.toBinaryString(Integer.valueOf(str)));                    }else if(Integer.valueOf(strs[0])>=1){//判断整数部分是否大于1                        l1 = Integer.toBinaryString(Integer.valueOf(strs[0]));//得到整数部分二进制                                            }else if(str.startsWith("-")){                            l1 =Integer.toBinaryString(Integer.valueOf(strs[0]));                    }else{                            l1 = "0";                    }                                        //得到小数部分的二进制                    String xiao = "0."+strs[1];                    double xiaoShu = Double.valueOf("0."+strs[1]);                    //System.out.println(xiaoShu);                    String l2;//小数部分二进制                    double b = 0;//每次的乘积                    int count = xiao.length();                    StringBuilder sb = new StringBuilder();                    while(count>=0){                        b = xiaoShu*2;                    if(b>=1){                        sb.append(1);                        xiaoShu = b-1;                    }else if(xiaoShu==0){                        break;                    }else{                        sb.append(0);                        xiaoShu = b;                    }                        count--;                    }                    //输出二进制                    System.out.println("二进制:"+l1+"."+sb);                    //判断是否继续                    if(!sel()){                        shiZhuanErBL = false;                    }                }                        }        }    }    //-------------------------十进制转成八进制---------------------------    public void shiZhuanBa(){        //定义断点        boolean shiZhuanBaBL = true;        while(shiZhuanBaBL){            new Menus().shiZhuanBaMenu();            String str = new Scanner(System.in).nextLine();            if(shuZi(str)){                String regex2 = "-?[0-9]*";                boolean n = str.matches(regex2);                //整数部分的八进制                String l1 = "";                if(n){                    System.out.println("八进制:"+Integer.toOctalString(Integer.valueOf(str)));                    //判断是否继续                    if(!sel()){                        shiZhuanBaBL = false;                    }                }else if(catc(str)){                    String [] strs = str.split("\\.");                    System.out.println("八进制:"+Integer.toOctalString(Integer.valueOf(strs[0])));                    //判断是否继续                    if(!sel()){                        shiZhuanBaBL = false;                    }                }else{                    //分割字符串,得到整数部分和小数部分                    String [] strs2 = str.split("\\.");                    if(strs2[1]==""){                        System.out.println("八进制:"+Integer.toOctalString(Integer.valueOf(str)));                    }else if(Integer.valueOf(strs2[0])>=1){//判断整数部分是否大于1                        l1 = Integer.toOctalString(Integer.valueOf(strs2[0]));//得到整数部分八进制                                            }else if(str.startsWith("-")){                        l1 = Integer.toOctalString(Integer.valueOf(strs2[0]));                    }else{                        l1 = "0";                    }                                        //得到小数部分的八进制                    String xiao = "0."+strs2[1];                    double xiaoShu = Double.valueOf("0."+strs2[1]);                    //System.out.println(xiaoShu);                    String l2;                    double b = 0;//每次的乘积                    int count = xiao.length();                    StringBuilder sb = new StringBuilder();                    while(count>=0){                        b = xiaoShu*8;                        if((int)b>=1){                            sb.append((int)b);                            xiaoShu = b-(int)b;                        }else if(xiaoShu==0){                            break;                        }else{                            sb.append(0);                            xiaoShu = b;                        }                        count--;                    }                    System.out.println("八进制:"+l1+"."+sb);                    //判断是否继续                    if(!sel()){                        shiZhuanBaBL = false;                    }                }                    }        }    }    //-------------------------十进制转成十六进制---------------------------    public void shiZhuanShiLiu(){        //定义断点        boolean shiZhuanShiLiuBL = true;        while(shiZhuanShiLiuBL){            new Menus().shiZhuanShiLiuMenu();            String str = new Scanner(System.in).nextLine();            if(shuZi(str)){                String regex2 = "-?[0-9]+";                boolean n = str.matches(regex2);                //整数部分的十六进制                String l1 = "";                if(n){                    System.out.println("十六进制:"+Integer.toHexString(Integer.valueOf(str)));                    //判断是否继续                    if(!sel()){                        shiZhuanShiLiuBL = false;                    }                }else if(catc(str)){                    String [] strs = str.split("\\.");                    System.out.println("十六进制:"+Integer.toHexString(Integer.valueOf(strs[0])));                    //判断是否继续                    if(!sel()){                        shiZhuanShiLiuBL = false;                    }                }else{                    //分割字符串,得到整数部分和小数部分                    String [] strs2 = str.split("\\.");                    if(strs2[1]==""){                        System.out.println("十六进制:"+Integer.toHexString(Integer.valueOf(str)));                    }else if(Integer.valueOf(strs2[0])>=1){//判断整数部分是否大于1                        l1 = Integer.toHexString(Integer.valueOf(strs2[0]));//得到整数部分十六进制                                            }else if(str.startsWith("-")){                        l1 = Integer.toHexString(Integer.valueOf(strs2[0]));                    }else{                        l1 = "0";                    }                    //得到小数部分的十六进制                    String xiao = "0."+strs2[1];                    double xiaoShu = Double.valueOf("0."+strs2[1]);                    //System.out.println(xiaoShu);                    String l2;//小数部分十六进制                    double b = 0;//每次的乘积                    int count = xiao.length();                    StringBuilder sb = new StringBuilder();                    while(count>=0){                        b = xiaoShu*16;                        if((int)b>=1){                            sb.append((int)b);                            xiaoShu = b-(int)b;                        }else if(xiaoShu==0){                            break;                        }else{                            sb.append(0);                            xiaoShu = b;                        }                        count--;                    }                    System.out.println("十六进制:"+l1+"."+sb);                    //判断是否继续                    if(!sel()){                        shiZhuanShiLiuBL = false;                    }                }            }        }    }    //------------------------------十六进制转其他进制--------------------------------    public void shiLiuZhuanQiTa(){        Menus menus = new Menus();//创建菜单对象        //定义断点        boolean shiLiuZhuanQiTaBL = true;        //while循环        while(shiLiuZhuanQiTaBL){            menus.shiLiuZhuanQiTaMenus();            switch(new Scanner(System.in).nextLine()){            case "1":                shiLiuZhuanEr();                break;            case "2":                shiLiuZhuanBa();                break;            case "3":                shiLiuZhuanShi();                break;            case "4":                shiLiuZhuanQiTaBL = false;                break;            case "":                menus.shiKongMenu();                break;                default:                    menus.shuRuCuoWuMenu();                    break;            }        }    }    //-------------------------十六转二--------------------------    public void shiLiuZhuanEr(){        //定义断点        boolean shiLiuZhuanEr = true;        while(shiLiuZhuanEr){            new Menus().shiLiuZhuanErMenu();            String sel = new Scanner(System.in).nextLine();            String shi = "";            if(shiShiLiuJinZhi(sel)){                System.out.println("二进制:"+Integer.toBinaryString(Integer.valueOf(Integer.valueOf(sel,16).toString())));                //判断是否继续                if(!sel()){                    shiLiuZhuanEr = false;                }            }else{                new Menus().shuRuCuoWuMenu();            }        }    }    //-------------------------十六转八--------------------------    public void shiLiuZhuanBa(){        //定义断点        boolean shiLiuZhuanBaBL = true;        while(shiLiuZhuanBaBL){            new Menus().shiLiuZhuanBaMenu();            String sel = new Scanner(System.in).nextLine();            String shi = "";            if(shiShiLiuJinZhi(sel)){                System.out.println("八进制:"+Integer.toOctalString(Integer.valueOf(Integer.valueOf(sel,16).toString())));                //判断是否继续                if(!sel()){                    shiLiuZhuanBaBL = false;                }            }else{                new Menus().shuRuCuoWuMenu();            }        }    }    //-------------------------十六转十--------------------------    public void shiLiuZhuanShi(){        //定义断点        boolean shiLiuZhuanShiBL = true;        while(shiLiuZhuanShiBL){            new Menus().shiLiuZhuanShiMenu();            String sel = new Scanner(System.in).nextLine();            String shi = "";            if(shiShiLiuJinZhi(sel)){                System.out.println("十进制:"+Integer.valueOf(Integer.valueOf(sel,16).toString()));                //判断是否继续                if(!sel()){                    shiLiuZhuanShiBL = false;                }            }else{                new Menus().shuRuCuoWuMenu();            }        }    }    //-------------------------输入判断Yes or No---------------------------    public boolean sel(){        boolean bl = true;        new Menus().shiFouJiXuMenu();        String str = new Scanner(System.in).nextLine();        if(str.equalsIgnoreCase("Y")){            return true;        }else if(str.equalsIgnoreCase("N")){            return false;        }else {            new Menus().shuRuCuoWuMenu();            bl = sel();        }        return bl;    }        //-------------------------判断是否为数字----------------------------    //判断是否为数字    public static boolean shuZi(String str){        String regex1 = "-?[0-9]+(\\.[0-9]+)?";        boolean returnBoolean;        boolean m = str.matches(regex1);        if(str ==""){            new Menus().shiKongMenu();                        returnBoolean = false;        }else if(m){                        returnBoolean = true;        }else{            new Menus().buShiShuZiMenu();            returnBoolean = false;        }        return returnBoolean;    }    //-------------------------判断.后面的数字是否等于0----------------------------    //判断.后面的数是否等于0    public static boolean catc(String str){        boolean bl = false;        String [] strs = str.split("\\.");        if(Integer.valueOf(strs[1])==0){            bl = true;        }        return bl;    }    //-----------------------------判断是否是二进制----------------------------------    //判断是否为二进制    public static boolean shiErJinZhi(String str){        boolean er = false;    /*    char[] ch = str.toCharArray();        for(char c : ch){            if(c =='0' || c == '1'){                er = true;            }        }*/        String regex = "[10]+";        if(str.matches(regex)){            er = true;        }        return er;    }    //-----------------------------判断是否是八进制----------------------------------    //判断是否为八进制    public static boolean shiBaJinZhi(String str){        boolean ba = false;        char[] ch = str.toCharArray();        for(char c : ch){            if(c >= '0' &&  c<= '7'){                ba = true;            }        }        return ba;    }    //----------------------------判断是否是十六进制-----------------------------------    //判断是否为十六进制    public static boolean shiShiLiuJinZhi(String str){        boolean ba = false;        String str1 = "-?[0-9A-Fa-f]+";        if(str.matches(str1)){            ba = true;        }        return ba;    }}