标签:system exception length com segment any throw bsp cep
https://leetcode.com/problems/number-of-segments-in-a-string/
package com.company; class Solution { public int countSegments(String s) { String[] strs = s.split(" "); int count = 0; for (String str : strs) { if (str.length() > 0) { count++; } } return count; } } public class Main { public static void main(String[] args) throws InterruptedException { String s = "Hello, my name is John"; Solution solution = new Solution(); int ret = solution.countSegments(s); // Your Codec object will be instantiated and called as such: System.out.printf("ret:%d\n", ret); System.out.println(); } }
number-of-segments-in-a-string
标签:system exception length com segment any throw bsp cep
原文地址:http://www.cnblogs.com/charlesblc/p/6156090.html