Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: SUBSTRING

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default SUBSTRING

    import javax.swing.*;

    public class Substring{
    public static void main (String a[]){

    String m = JOptionPane.showInputDialog("Enter a String:");
    String sub = JOptionPane.showInputDialog("Enter a Substring:");
    String temp = "";
    int num = 0;

    for (int x=0;x<m.length();x++){
    for (int y=0;y<sub.length();y++){
    temp = temp + m.charAt(x);
    }
    if (temp.equalsIgnoreCase(sub)){
    num++;

    }
    temp="";
    }
    JOptionPane.showMessageDialog(null,"Number of occurence of substring" + sub + " in string" + m + "is" + num);
    }
    }


  2. #2
    Member
    Join Date
    Oct 2010
    Posts
    40
    Thanks
    0
    Thanked 2 Times in 1 Post

    Default Re: SUBSTRING

    whats wrong with tihs?

Similar Threads

  1. Substring help
    By Roach in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 21st, 2010, 07:57 AM
  2. [SOLVED] replacing subString
    By nasi in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 21st, 2010, 09:47 PM
  3. Substring function
    By bristol580 in forum Java SE APIs
    Replies: 2
    Last Post: November 12th, 2009, 11:29 AM
  4. First string is a substring of another
    By mgutierrez19 in forum What's Wrong With My Code?
    Replies: 13
    Last Post: October 21st, 2009, 10:35 PM
  5. Substring program, not working
    By Newoor in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 18th, 2009, 12:46 PM

Tags for this Thread