parul_bansal's blog

By parul_bansal, history, 6 years ago, In English

I am new in java . I don't know how to debug the error mentioned above in my code . Please help me.

import java.util.*; import java.lang.*; import java.io.*;

class S { public static void main(String args[]){ String s1,s2; Scanner sc = new Scanner(System.in); s1 = sc.nextLine(); s2 = sc.nextLine();

int index=0,sum=0;
    while(index!=-1){

        index = s1.indexOf(s2,index);
        if(index!=-1){
            sum ++;
            index += s2.length();
        }
    }
    System.out.println(sum);
}

}

 
 
 
 
  • Vote: I like it
  • -6
  • Vote: I do not like it

»
6 years ago, # |
Rev. 3   Vote: I like it +10 Vote: I do not like it

try public class S

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Class must be public