快捷导航

为什么不能成功检错?

package com.xesivo;import java.util.Scanner;public class MSLibrary {        static int consent1 = 0;        static int consent2 = 0;        static int imput = 0;        public static void methSel() throws Exception{                Scanner in = new Scanner(System.in);                int a = in.nextInt();                if(a != 1){                        if(a != 2){                                Exception e = new Exception();                                throw e;                        }                        }                imput = a;                consent1 = 1;        }                public static void numSe() throws Exception{                Scanner in = new Scanner(System.in);                int a = in.nextInt();                if(a < 0){                        Exception e = new Exception();                        throw e;                }                if(a > 8){                        Exception e = new Exception();                        throw e;                }                for(int i = 1; i

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员1

字符串是否相等用equals函数
判断条件
a != "孟子"    换成  !a.equals("孟子")
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP