Split string uusing Java   Independent houses near kukatpally | Apartments in Pragathi Nagar | AndhraVaani.com | Log Out | Topics | Search
Register | Edit Profile

Bewarse TalkArchives - 2007Cine Talk - Reviews, Gossips, Insider Info etc.Archive through February 09, 2007 � Split string uusing Java Previous Next

Author Message
Top of pagePrevious messageNext messageBottom of pageLink to this 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:Edit PostDelete PostView Post/Check IP

np
Top of pagePrevious messageNext messageBottom of pageLink to this message

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:Edit PostDelete PostView Post/Check IP

Firefox mama than x alot mama. thanx once again.
Manchikaina Punchikaina denikaina siddam siddam ra
Top of pagePrevious messageNext messageBottom of pageLink to this message

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:Edit PostDelete PostView Post/Check IP

Top of pagePrevious messageNext messageBottom of pageLink to this message

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:Edit PostDelete PostView Post/Check IP

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();
}
}
Top of pagePrevious messageNext messageBottom of pageLink to this message

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:Edit PostDelete PostView Post/Check IP

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);
}
Top of pagePrevious messageNext messageBottom of pageLink to this message

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:Edit PostDelete PostView Post/Check IP

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
Top of pagePrevious messageNext messageBottom of pageLink to this message

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:Edit PostDelete PostView Post/Check IP

Firefox mama using string tokenizer mama.
Manchikaina Punchikaina denikaina siddam siddam ra
Top of pagePrevious messageNext messageBottom of pageLink to this message

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:Edit PostDelete PostView Post/Check IP

ardham kaledu
Top of pagePrevious messageNext messageBottom of pageLink to this message

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:Edit PostDelete PostView Post/Check IP

code unda mama.
Manchikaina Punchikaina denikaina siddam siddam ra
Top of pagePrevious messageNext messageBottom of pageLink to this message

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:Edit PostDelete PostView Post/Check IP

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
Top of pagePrevious messageNext messageBottom of pageLink to this message

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:Edit PostDelete PostView Post/Check IP

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