Question
What's wrong with this code ?

public static void main(String[] args) {
String regex = "(w+)*";
String s = "Java is a programming language.";

Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(s);
while (matcher.next()) {
System.out.println("The e-mail id is: " + matcher.group());
}
}

Answers

matcher.find() should have been used instead of matcher.next() within while.   Your Comment




More Software,W,Java Questions..
What is the inputsplit in map reduce software?

Can variables be used in Java without initialization?

What is the difference between java bean and enterprise java bean?

What is software configuration management?

How does the java database connectivity (jdbc) work?

What are the advantages of threads in java?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

What is object cloning in Java?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?



Search
Can you Answer!!
  • Q Being a girl, why did you choose civil engineering?
  • Q What is hypothecation?
  • Q Does each thread in java uses seperate stack?
  • Q You are creating an ASP.NET page that contains a Label control named specialsLabel. A text file named Specials.txt contains a list of products. Specials.txt is located in the application directory. Each product name listed in Specials.txt is followed by a carriage return. You need to display a list of featured products in specialsLabel. You need to retrieve the lost of products from Specials.txt. Which code segment should you use? A. System.IO.StreamReader reader = System.IO.File.OpenText(Server.MapPath(Specials.txt)); string inout = ; while (input !=null) { specialsLabel.Text = string.Format({0}
    {1} , specialsLabel.Text, input); input = reader.BaseStream.ToString(); } reader.Close(); B. System.IO.StreamReader reader = System.IO.File.OpenText( Server.MapPath(Specials.txt)); string inout = ; input = reader.ReadLine(); while (input != null) { specialsLabel.Text = string.Format({0}
    {1} , specialsLabel.Text, input); input = reader.ReadLine(); } reader.Close() C. System.IO.Stream strm = System.IO.File.OpenRead( Server.MapPath(Specials.txt)); byte[] b 0 new byte[1024]; string input; input = strm.Read(b, 0, b.Length).ToString(); specialsLabel.Text = input strm.Close(); D. System.IO.Stream strm = System.IO.File.OpenRead( Server.MapPath(Specials.txt)); string input; input = strm.ToString(); specialsLabel.Text = input; strm.Close();
  • Q What is difference between View State and Hidden Field in ASP.NET?
  • Q Difference between arrays and linked list?
  • Q Which attribute adorn a test class to be picked up by the NUnit GUI in the NUnit test framework?
  • Q How do u migrate bo 6.x to xi?
  • Q The alcohol which is present in the alcoholic beverages is?
  • Q Tim Morse has been appointed as chief financial officer by which of the internet giants?
  • Q Where is the Headquarters of Prambikulam Wildlife Santuary, which has entrance only through Tamilnadu?