Results 1 to 5 of 5
  1. #1
    sireesha is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Question String operations..

    Hi friends,
    can u please tell me..
    how to verify the presence of a particular sequence of characters in a string ?
    is there any method for this ?
    thankq

  2. #2
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

  3. #3
    sireesha is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Default

    thankq,
    i learned more about string from that tutorial.
    but i couldn't get answer to my question from that.
    i want to varify the presence of particular sequence of characters in a string.
    (for example we have to check the presence of "java" in the string "string operations in java ".)
    such method have to return boolean type date depends on the presence of string.
    is there any such method ?
    please tell me...

  4. #4
    rajiv_bang is offline Member
    Join Date
    Nov 2007
    Posts
    11
    Rep Power
    0

    Default

    A small example to get you started.


    Java Code:
    import java.util.*;
    public class FindString
    {
    public static void main(String args[])
     {
    	String s1 = "String operations in java";
    	
    	if(s1.indexOf("java")>-1)
    		System.out.println("Found");
    	else
    		System.out.println("Not found");
     }
    }

  5. #5
    staykovmarin is offline Senior Member
    Join Date
    Nov 2007
    Location
    Newport, WA
    Posts
    141
    Rep Power
    0

    Default

    Java Code:
    String s = "foobar";
    if (s.contains("bar")) 
            // it conains

Similar Threads

  1. Stack push/pop/peek operations
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-29-2008, 10:03 AM
  2. Uses unchecked or unsafe operations message
    By Robbinz in forum New To Java
    Replies: 2
    Last Post: 12-06-2007, 11:56 PM
  3. Replies: 0
    Last Post: 11-20-2007, 05:59 PM
  4. Replies: 1
    Last Post: 08-07-2007, 08:29 AM
  5. Replies: 1
    Last Post: 08-03-2007, 11:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •