Java 读入一行字符串(不多于 800 个字符,以回车结束),统计其中 Bubble 出现了多少次。

问题遇到的现象和发生背景

读入一行字符串(不多于 800 个字符,以回车结束),统计其中 Bubble 出现了多少次。

问题相关代码,请勿粘贴截图

/*

  • To change this license header, choose License Headers in Project Properties.

  • To change this template file, choose Tools | Templates

  • and open the template in the editor.

  • /
    package javaapplication12;
    import java.util.Scanner;
    /**

  • @author H7x

  • /
    public class JavaApplication12 {

    /**

    • @param args the command line arguments
    • /
      public static void main(String[] args) {
      // TODO code application logic here
      int num=0;
      String str = "Bubble";
      Scanner input=new Scanner(System.in);
      String s=input.nextLine();
      char w,e,r;
      for(int i =0;i<s.length();i++){
        w = s.charAt(i);
        if(w=='B'){
            int j,k;
            
            for(j = 0,k = i;j<6;j++,k++){
                e = s.charAt(k);
                r = str.charAt(j);
                if(e!=r);
                break;
        }
        if(j==6)
            num++;
        }
      
      }
      System.out.print(num);
      }
      }
运行结果及报错内容

Bubble is ajdaod
0

我的解答思路和尝试过的方法
我想要达到的结果

怎么正确输出Bubble有几个呀

Char w; Listsss=new ArrayList(); for(int i=0;i