相关疑难解决方法(0)

如何检查char数组是否有空单元格,以便在其中打印0?

码:

public void placeO(int xpos, int ypos) {
    for(int i=0; i<3;i++)
        for(int j = 0;j<3;j++) {
            // The line below does not work. what can I use to replace this?
            if(position[i][j]==' ') {
                position[i][j]='0';
            }
        }
}
Run Code Online (Sandbox Code Playgroud)

java loops compare char charat

5
推荐指数
2
解决办法
3万
查看次数

如何检查一个字符是否为空

我想检查字符是否为空?但为什么这段代码不起作用?letterChar == null也不起作用。我用谷歌搜索了很多问题,但没有看到任何解决方案,大多数解决方案都是关于String.

String letter = enterletter.getText().toString();
char letterChar = letter.charAt(0);


if(letterChar == ' ' || letterChar == NULL) // this is where the code won't works
{
    Toast.makeText(getApplicationContext(), "Please enter a letter!", Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)

java android

5
推荐指数
1
解决办法
6万
查看次数

标签 统计

java ×2

android ×1

char ×1

charat ×1

compare ×1

loops ×1