Bluej 错误:二进制操作的操作数类型错误&&;

Bluej 错误:二进制操作的操作数类型错误&&;,bluej,Bluej,这是密码 import java.io.*; class WORD2 { public void main() throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the sentence"); String str=br.readLine().toUpper

这是密码

import java.io.*;
class WORD2
 {  
public void main() throws IOException
{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Enter the sentence");
        String str=br.readLine().toUpperCase()+" ";
        int l=str.length();
        String word="";
        int p=0;
        String word2[]=new String[l];
        for(int i=0;i<str.length();i++)
        {
            char ch=str.charAt(i);
            **if((str.charAt(i))&&(str.charAt(i+1)!= ' '))**// THE ERROR COMES IN THIS STATEMNET SHOWING THE ERROR
            {
                if(ch!=' ')
                {
                    word=word+ch;   //TAKING EACH WORD
                }
                else 
                {
                    word2[p++]=word;  //STORING EACH WORD
                    word="";
                }

        }}
        String q="";
            for(int k=0;k<p;k++)
            {
                q=q+word2[k]+" ";
            }
            System.out.print("q="+q);
        }}
import java.io.*;
类别词2
{  
public void main()引发IOException
{
BufferedReader br=新的BufferedReader(新的InputStreamReader(System.in));
System.out.println(“输入句子”);
字符串str=br.readLine().toUpperCase()+“”;
int l=str.length();
字串=”;
int p=0;
字符串字2[]=新字符串[l];
对于(int i=0;i

是正确的语法,因为如果需要布尔(true /false)来考虑。 第一部分返回char。 另外,在str.charAt(i+1)进行检查,否则您将获得StringIndexOutOfBoundsException

if((str.charAt(i)!= ' ' )&&(str.charAt(i+1)!= ' '))