Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TVString {
- public static int count(String s, char c) {
- int d = 0;
- for(int i = 0; i < s.length(); i++)
- if(s.charAt(i) == c) d++;
- return d;
- }
- public static int count(String s1, String s2) {
- int n,d = 0;
- n = s1.indexOf(s2);
- while (n >= 0)
- {
- d++;
- n = s1.indexOf(s2,n + s2.length());
- }
- return d;
- }
- public static int countWords(String s)
- {
- int n,d = 0;
- if (s.length()>0) d = 1;
- n = s.indexOf(" ");
- while (n >= 0)
- { d++;
- n = s.indexOf(" ",n+1); }
- return d;
- }
- public static String ten(String ht)
- {
- int n; String kq;
- ht = ht.trim();
- n = ht.lastIndexOf(" ");
- kq = ht.substring(n+1);
- return kq;
- }
- public static String ho(String ht)
- {
- int n; String kq;
- ht = ht.trim();
- n = ht.indexOf(" ");
- kq = ht.substring(0,n);
- return kq;
- }
- public static String dem(String ht){
- int m,n;
- String kq;
- ht = ht.trim();
- m = ht.indexOf(" ");
- n = ht.lastIndexOf(" ");
- kq = ht.substring(m+1, n);
- return kq;
- }
- }
Add Comment
Please, Sign In to add comment