java - 为什么这个方法不打印它的文本? (java)

标签 java methods

方法如下:

public static int chooseStrat () 
{ 
    String[] strats = new String[1] ; 
    strats[0] = "0 - Blob" ;
    int n ;
    boolean a = false ; 
    while (a == false) ;
    {
        System.out.println ("Which strategy should the AI use?(#)") ;
        printArrayS (strats) ; 
        n = getInt () ; 
        System.out.println ("you selected "+n+"."+" are you sure you want the computer to use the "+ strats[n]+ " ?(Y/N)") ;
        String c = getIns () ;  
        while ((((!(   (c.equals ("y")) || (c.equals ("Y"))   )) && (!( (c.equals ("n")) ||  (c.equals ("N")) ) ) ))) ;
        {   
            System.out.println ("try again") ;
            c = getIns () ;
        }
        if ( (c.equals ("Y")) || (c.equals ("y")) ) 
            a = true ; 
    }
    return n ; 
} 

当我运行它时,它永远不会打印“AI 应该使用哪种策略?(#)”,它只是尝试从键盘获取输入。为什么要这样做?

最佳答案

while () *;* 没有执行您想要的操作,请删除分号。

顺便说一句,任何像样的 java 编译器都会警告你这一点,你读过它告诉你的内容吗?

关于java - 为什么这个方法不打印它的文本? (java),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2557391/

相关文章:

java - 不断接收对其自身的赋值,并丢失方法体错误

python - Scrapy 解析方法的参数

java - 通过套接字读写字节数据包

java - 在链接列表中使用对象/继承类

java - JRE 1.7.0_51-b13 和签名的小程序

java - 声明类类型的方法?

c# - 使用显式接口(interface)防止意外修改 C# 中的属性

Java 泛型难题

java.lang.NullPointerException : null when using Spring Boot

Php PDO,类方法返回真而参数中的列名错误?