Advertisement
Xetos

StringTokenizer - szavak szama

Apr 20th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1.  
  2. import java.util.StringTokenizer;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String[] args) {
  7.         String s = "sor amit tordelni kell";
  8.         StringTokenizer st = new StringTokenizer(s);
  9.         st = new StringTokenizer(s," ");
  10.         int hossz = 0;
  11.         while(st.hasMoreTokens()){
  12.             String resz = st.nextToken();
  13.             hossz++;
  14.         }
  15.  
  16.        
  17.         System.out.println("Szavak szama: "+hossz);
  18.  
  19.     }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement