Author |
Message |
    
Firefox
Pilla Bewarse Username: Firefox
Post Number: 272 Registered: 12-2004 Posted From: 68.36.46.168
| Posted on Friday, February 02, 2007 - 7:46 pm: |    |
np |
    
Esperanza
Vooriki Bewarse Username: Esperanza
Post Number: 3208 Registered: 08-2004 Posted From: 88.73.59.136
| Posted on Friday, February 02, 2007 - 6:56 pm: |    |
Firefox mama than x alot mama. thanx once again. Manchikaina Punchikaina denikaina siddam siddam ra |
    
Moneymaker
Pilla Bewarse Username: Moneymaker
Post Number: 84 Registered: 01-2007 Posted From: 192.76.82.89
| Posted on Friday, February 02, 2007 - 4:09 pm: |    |
 |
    
Firefox
Pilla Bewarse Username: Firefox
Post Number: 271 Registered: 12-2004 Posted From: 208.253.136.131
| Posted on Friday, February 02, 2007 - 2:18 pm: |    |
import java.util.Hashtable; import java.util.Iterator; import java.util.StringTokenizer; public class Test { public void run(){ String[] names={"vamsi krishna","vikram bhayya","gada crick","vikram ksfdsf","vikram ksfsdf"}; Hashtable ht= new Hashtable(); StringTokenizer st; StringBuffer sb; for(int i=0;i<names.length;i++){ st=new StringTokenizer(names[i]," "); sb=new StringBuffer(); while(st.hasMoreTokens()){ sb.append(st.nextToken().charAt(0)); } ht.put(GenerateKey(ht,sb.toString()),names[i]); //System.out.println("Name: "+names[0]+" FirstLetters: "+sb); } printHashTable(ht); } private String GenerateKey(Hashtable ht,String key){ Iterator it = ht.keySet().iterator(); int keyCount=0; while(it.hasNext()){ if(((String)it.next()).indexOf(key)>-1)keyCount++; } return key+keyCount; } private void printHashTable(Hashtable ht){ Iterator it = ht.keySet().iterator(); while(it.hasNext()){ Object key=it.next(); System.out.println("Name: "+ht.get(key)+" FirstLetters: "+key); } } public static void main(String[] args) { new Test().run(); } } |
    
Firefox
Pilla Bewarse Username: Firefox
Post Number: 270 Registered: 12-2004 Posted From: 208.253.136.131
| Posted on Friday, February 02, 2007 - 1:48 pm: |    |
String[] names={"vamsi krishna","vikram bhayya","gada crick"}; StringTokenizer st; StringBuffer sb; for(int i=0;i<names.length;i++){ st=new StringTokenizer(names[i]," "); sb=new StringBuffer(); while(st.hasMoreTokens()){ sb.append(st.nextToken().charAt(0)); } System.out.println("Name: "+names[0]+" FirstLetters: "+sb); } |
    
Esperanza
Vooriki Bewarse Username: Esperanza
Post Number: 3203 Registered: 08-2004 Posted From: 88.73.21.138
| Posted on Friday, February 02, 2007 - 9:06 am: |    |
split() string Q- suppose i have a string like "vamsi krishna" .i want to split the string and add the first letters of each string. from the above string the answer i should get is like "VK". and another doubt is that using string tokenizer if ive entered vamsi krishna it will take "vk" and if i enter vikram kumar then also it will take "vk" is there any method in java to increment like "vk001" "vk002" inorder to differentiate the names like that.i hope u got me.. please send the code for this. thank you Manchikaina Punchikaina denikaina siddam siddam ra |
    
Esperanza
Vooriki Bewarse Username: Esperanza
Post Number: 3202 Registered: 08-2004 Posted From: 88.73.21.138
| Posted on Friday, February 02, 2007 - 9:03 am: |    |
Firefox mama using string tokenizer mama. Manchikaina Punchikaina denikaina siddam siddam ra |
    
Firefox
Pilla Bewarse Username: Firefox
Post Number: 269 Registered: 12-2004 Posted From: 208.253.136.131
| Posted on Friday, February 02, 2007 - 8:49 am: |    |
ardham kaledu |
    
Esperanza
Vooriki Bewarse Username: Esperanza
Post Number: 3195 Registered: 08-2004 Posted From: 88.73.7.172
| Posted on Friday, February 02, 2007 - 5:46 am: |    |
code unda mama. Manchikaina Punchikaina denikaina siddam siddam ra |
    
Beer
Bewarse Username: Beer
Post Number: 2301 Registered: 09-2006 Posted From: 208.204.155.241
| Posted on Friday, February 02, 2007 - 4:39 am: |    |
use StringTokenizer and then use substring check the java doc for the StringTokenizer. it is fairly easy, Beauty lies in the eye of the beer holder  |
    
Esperanza
Vooriki Bewarse Username: Esperanza
Post Number: 3191 Registered: 08-2004 Posted From: 88.73.7.172
| Posted on Friday, February 02, 2007 - 4:34 am: |    |
i have a doubt. if ive entered vamsi krishna it will take "vk" and if i enter vikram kumar then also it will take "vk" is there any method in java to increment like "vk001" "vk002" like that.i hope u got me..if u dont mind could u plz send me the code.. thanks in advance.. Manchikaina Punchikaina denikaina siddam siddam ra |