Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.StringTokenizer; //StringTokenizer class
- class TokenTester {
- public static void main (String[] arguments){
- StringTokenizer st1, st2;
- String quote1="GOOG 530.80 -9,98";
- st1=new StringTokenizer (quote1); ///using the 'new' operator to create new object of the StringTokenizer class
- System.out.println("Token 1:" +st1.nextToken());
- System.out.println("Token 2:" +st1.nextToken());
- System.out.println("Token 3:" +st1.nextToken());
- String quote2="RHT@75.00@0.22";
- /*when you use 'new' operator a new instance of the class is
- * created and a method defined in the class,
- * called a constructor, it intialises the new object and its variables
- */
- st2 = new StringTokenizer(quote2, "@");//takes two arguements
- System.out.println("\nToken 1:" +st2.nextToken());
- System.out.println("\nToken 2:" +st2.nextToken());
- System.out.println("\nToken 3:" +st2.nextToken());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement