/* * Created on Jul 28, 2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package TestClasses; import java.util.*; /** * @author student * * This class is being used for testing usage of StringTokenizer to * tokenize a coffee description. * */ public class StringTest { /** * Method: main * This method is being used for checking the string tokenizer usage. * @param args arguments, not used. * @return void */ public static void main(String[] args){ String type = "Caffe Latte - small $2.80"; StringTokenizer st = new StringTokenizer(type, "-"); st.nextToken(); StringTokenizer st2 = new StringTokenizer(st.nextToken(), " "); String size = st2.nextToken(); String price = st2.nextToken(); System.out.println("Size : "+size); System.out.println("Price : "+price); price = price.substring(1, price.length()); System.out.println("Price : "+price); double dbPrice = Double.valueOf(price).doubleValue(); System.out.println("Price : "+dbPrice); } }