working wit string

working wit string

View Answers

November 14, 2009 at 9:56 AM

Hi Friend,

Try the following code:

import java.util.*;
import java.util.regex.*;

public class StringExample {
public static void main(String[]args){
String st="hello! how are you? when are you coming? hope to see u soon.";
String s1="",s2="",s3="",s4="";
Pattern p=Pattern.compile("[?!.]");
String arr[]=p.split(st);
for(int i=0;i<arr.length;i++){
s1=arr[0];
s2=arr[1];
s3=arr[2];
s4=arr[3];
}
String st1="",st2="",st3="",st4="";
String a1[]=s1.split(" ");
Arrays.sort(a1);
for(int i=0;i<a1.length;i++){
st1+=a1[i];
}
String a2[]=s2.split(" ");
Arrays.sort(a2);
for(int i=0;i<a2.length;i++){
st2+=a2[i]+" ";
}
String a3[]=s3.split(" ");
Arrays.sort(a3);
for(int i=0;i<a3.length;i++){
st3+=a3[i]+" ";
}
String a4[]=s4.split(" ");
Arrays.sort(a4);
for(int i=0;i<a4.length;i++){
st4+=a4[i]+" ";
}
System.out.println(st1+"! "+st2+"? "+st3+"? "+st4+".");
}
}

Thanks

November 14, 2009 at 10:45 AM

Hi Friend,

import java.util.*;
import java.util.regex.*;

public class Vowels {
public static void main(String[]args){
String st="hello! how are you? when are you coming? hope to see u soon.";
String str=st.replaceAll("[?!.]","");
StringTokenizer tokenizer = new StringTokenizer(str);
String s="";
while(tokenizer.hasMoreTokens()){
s=tokenizer.nextToken();
if((s.startsWith("a"))||(s.startsWith("e"))||(s.startsWith("i"))||(s.startsWith("o"))||(s.startsWith("u"))){
System.out.println(s);
}
}

}
}

Thanks









Related Tutorials/Questions & Answers:
working wit string - Java Beginners
working wit string  accept a paragraph of text. consisting... StringExample { public static void main(String[]args){ String st="hello! how are you? when are you coming? hope to see u soon."; String s1="",s2="",s3="",s4
ModuleNotFoundError: No module named 'wit'
ModuleNotFoundError: No module named 'wit'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'wit' How to remove the ModuleNotFoundError: No module named 'wit' error
Advertisements
ModuleNotFoundError: No module named 'ckan-wit'
ModuleNotFoundError: No module named 'ckan-wit'  Hi, My Python... 'ckan-wit' How to remove the ModuleNotFoundError: No module named 'ckan-wit... to install padas library. You can install ckan-wit python with following
ModuleNotFoundError: No module named 'brittle_wit'
ModuleNotFoundError: No module named 'brittle_wit'  Hi, My Python... 'brittle_wit' How to remove the ModuleNotFoundError: No module named 'brittle_wit' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'ckan-wit'
ModuleNotFoundError: No module named 'ckan-wit'  Hi, My Python... 'ckan-wit' How to remove the ModuleNotFoundError: No module named 'ckan-wit... to install padas library. You can install ckan-wit python with following
Spring wit hibernate - Spring
Spring wit hibernate  when i m trying to access the data using spring with hibernate DAo framwork, i m geeting session closed exception. some thing like this org.hibernate.LazyInitializationException: could not initialize proxy
ModuleNotFoundError: No module named 'tensorboard-plugin-wit'
ModuleNotFoundError: No module named 'tensorboard-plugin-wit'  Hi...: No module named 'tensorboard-plugin-wit' How to remove the ModuleNotFoundError: No module named 'tensorboard-plugin-wit' error? Thanks   Hi
ModuleNotFoundError: No module named 'tensorboard-plugin-wit'
ModuleNotFoundError: No module named 'tensorboard-plugin-wit'  Hi...: No module named 'tensorboard-plugin-wit' How to remove the ModuleNotFoundError: No module named 'tensorboard-plugin-wit' error? Thanks   Hi
ModuleNotFoundError: No module named 'tensorboard-plugin-wit'
ModuleNotFoundError: No module named 'tensorboard-plugin-wit'  Hi...: No module named 'tensorboard-plugin-wit' How to remove the ModuleNotFoundError: No module named 'tensorboard-plugin-wit' error? Thanks   Hi
ModuleNotFoundError: No module named 'brittle_wit_core'
ModuleNotFoundError: No module named 'brittle_wit_core'  Hi, My... named 'brittle_wit_core' How to remove the ModuleNotFoundError: No module named 'brittle_wit_core' error? Thanks   Hi, In your
UITapgesturerecognizer not working
UITapgesturerecognizer not working  uitapgesturerecognizer not working
STRING.....
STRING.....  plzz sent me d code for counting vowels in a string... gui programme
string
string   difference detween "public static void main (String[] args) " and "public static void main (String args[])" in java but it executes both... "String args[]" can mean a "string array called args which is an array
string
string  String helloString = new String(helloArray); System.out.println(helloString); i am unable to understand this. could u plz explain
string
string  a java program using string function to input any string... ArrangeStringAlphabetically { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter string
String
String  how to add spaces with string functions.?   Hi... { public static String addSpaceToRight(String s, int n) { return String.format("%1$-" + n + "s", s); } public static String addSpaceToLeft(String s, int n
String
characters in string?   import java.util.*; class RemoveDuplicateCharatcersFromString { public static String removeDuplicates(String s... < s.length(); i++) { String st = s.substring(i, i + 1
String
String  write down the code of remove any character from a given string without using any string function   please give me the code of remove any given character from a given string without using function
string
string  a java program to input a string and display the string...*; import java.io.*; public class FirstLetter{ public static String capitalizeFirstLetter( String str ) { final StringTokenizer st = new StringTokenizer( str
string
*; class ExtractWords { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter String: "); String st=input.nextLine(); String str[]=st.split
string
string   just i want to a program in a short form to the given string in buffered reader for example input string: Suresh Chandra Gupta output: S. C...; public class StringTest { public static void main(String [] args
string
string  write a program to accept the string and store the reverse stream into another array and print
string
string  java prgm to find total occurence of a given string pattern in a sentence
string
string  java prgm to find total occurence of a given string pattern in a sentence
String
String  write a program using string it should replace 'c'char to integer number as 1 in whole source
String
String  How to Convert sunnapu gopal to Sunnapu Gopal in java using String
String
String  how to print in between numbers if the question "String s = "1,2,3,4,5,6,8,-25"" out must be 1 2,3,4,5,6,7,8,9,10,upto25
string
and also displaying that contain word? Like I want to find "a" in the string... and a character. It then count the occurrence of that character in the string and display... String_Example { public static void main(String[] args
string
string  program for String reverse and replace in c,c++,java e.g.Input:10,20,hello output:hello;20;10   Hi Friend, Try the following java...(String[] args) { String array[]=new String[5]; Scanner input
string
string  a java program using string function that computes your initials from your full name and display them   Please visit the following links: http://www.roseindia.net/tutorial/java/core/printInitials.html
string
string  a java program using string function and access modifiers to automate the insurance company which will have to manage the information about policy holders Data Members: 1)Policy No 2)Name of policy holder 3)Address 4
Why this is not working...?
Why this is not working...?  import java.util.*; public class Family..."); } } } public static void main(String[] args) { Person... and Person.java files.   public class Person { private String name
htpasswd working
htpasswd working   hii, What does htpasswd do?   hello,ADS_TO_REPLACE_1 htpasswd creates a new user in a specified group, and asks to specify a password for that user
hibernate.archive.autodetection not working
hibernate.archive.autodetection not working  Hi, What is the use of hibernate.archive.autodetection? I am trying to use in my project but its not working. How to resolve hibernate.archive.autodetection not working issue
Datagrid not working
Datagrid not working  The code here is working fine, apart from the fact that that I'm using netbeans 6.5 and the servlet v2.5 and struts 1.1.... working. please help me out
If-else not working
"><br></br> </form> <% String Lab=request.getParameter("Lab"); String query=null; if (Lab == "Lab"){ query
If-else not working
"><br></br> </form> <% String Lab=request.getParameter("Lab"); String query=null; if (Lab == "Lab"){ query
Update not working in hibernate.
Update not working in hibernate.  Update not working in hibernate
Comparing arrays not working correctly?
Comparing arrays not working correctly?  Comparing arrays not working correctly
Nitobi Grid is not working in IE10/IE11
Nitobi Grid is not working in IE10/IE11  Nitobi grid is working in IE8, but not working in IE10/IE11. we are using above two javascript files to open the grid
Focus method not working in firefox
Focus method not working in firefox  object.focus() is not working in firefox and chrome the element is not focused what was the problem
intern() of String
intern() of String  Please explain me the working of intern().   Hello Friend, You can compare String objects and string characters... information, visit the following link: String intern() method Thanks
ModuleNotFoundError: No module named 'working'
ModuleNotFoundError: No module named 'working'  Hi, My Python... 'working' How to remove the ModuleNotFoundError: No module named 'working... to install padas library. You can install working python with following command
ModuleNotFoundError: No module named 'working'
ModuleNotFoundError: No module named 'working'  Hi, My Python... 'working' How to remove the ModuleNotFoundError: No module named 'working... to install padas library. You can install working python with following command
ModuleNotFoundError: No module named 'working'
ModuleNotFoundError: No module named 'working'  Hi, My Python... 'working' How to remove the ModuleNotFoundError: No module named 'working... to install padas library. You can install working python with following command
code not working properly
code not working properly  protected void doPost(HttpServletRequest...); String target="jsp/hrms_default.jsp"; String action=request.getParameter("action_submit"); //String actionchngpswd=request.getParameter
calender working in struts - Struts
calender working in struts  when i execute the following code ,that is working properly if i convert to struts html tags that code is not working please help me to rectify the problem
html dropdown not working firefox
html dropdown not working firefox  I am writing a Dropdown code in HTML which is not working in firefox. What could be the reason as it's perfectly working in IE and Crome. Thanks
JTextfields working with JTextArea
JTextfields working with JTextArea  I have 2 database tables one... JButton("Patient History"); String driverName = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/record"; String userName = "root
Multi Threading is not working in that why...?
Multi Threading is not working in that why...?   import java.io.File... byte[] dataBytes2 = new byte[100000000]; public static void main(String[] args) throws IOException { String filename = "users14.dbf

Ads