title: java:25: class, interface, or enum expected public static void main(String s[]) {
body: <p>I am trying to make a program to count words of a string.</p>
  
  <p>The following is my code, and the errors coming in my code and I am unable to correct them:</p>
  
  <pre><code>import java.util.*;    
  class string1 {
      public static int wordcount() {
          String str;
          Scanner s1= new Scanner(System.in);
          System.out.println("Enter String:");
          str=s1.nextLine();
          int count=WCount(str);
          System.out.println("Count="+count);
      }
  
      public static int WCount(String str) {
          int l=str.length();
          int count=0;
          for(int i=0;i&lt;l;i++) {
              if(str.charAt(i)==' ')
                  count++ ;
          }
          if(count&gt;0) 
              count++ ;
          return(count);
      }
  }
  public static void main (String s[]) {
      string1 ss=new string1();
      ss.wordcount();
  }
  </code></pre>
  
  <p>Error : </p>
  
  <pre><code>java:25: class, interface, or enum expected
  public static void main(String s[]) {
            ^
  C:\Users\coocl\Desktop\java\string1.java:27: class, interface, or enum expected
  ss.wordcount();
  ^
  C:\Users\coocl\Desktop\java\string1.java:28: class, interface, or enum expected}3 errors
  
  Process completed.
  </code></pre>