Click here to Skip to main content
15,914,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
i have an string : I Am Here
so i want to split above string to get result : IAH

input : I Am Here
output : IAH

so how can i do ?

thank !
Posted

The following method takes a string as parameter and return the expected output. Pretty Simple

Java
private String getAcronym(String input) {
        String[] splits = input.split(" ");
        String result = "";
        for(int i=0;i<splits.length;i++){>
            result += splits[i].substring(0, 1);
        }
        return result;
    }
 
Share this answer
 
Java Strings Tutorial[^]

I'd start by looking at split[^] and substring[^]
 
Share this answer
 
see the below link

Click Here to see your answer...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900