<qiyuangong>434_Number_of_Segments_in_a_String_2.java
public int countSegments(String s) {
        int segmentCount = 0;

        for (int i = 0; i < s.length(); i++) {
            if ((i == 0 || s.charAt(i-1) == ' ') && s.charAt(i) != ' ') {
                segmentCount++;
            }
        }

        return segmentCount;
    }
public int sample_funcname ( String var_1 ) {
  int var_3 = 0 ;
  for ( int var_4 = 0 ;
  var_4 < var_1 . length ( ) ;
  var_4 ++ ) {
    if ( ( var_4 == 0 || var_1 . charAt ( var_4 - 1 ) == ' ' ) && var_1 . charAt ( var_4 ) != ' ' ) {
      var_3 ++ ;
    }
  }
  return var_3 ;
}
