Results 1 to 9 of 9

Thread: Patterns

  1. #1
    whosadork is offline Member
    Join Date
    Sep 2008
    Posts
    29
    Rep Power
    0

    Default Patterns

    How do i tell java to look for a pattern??

    like for say i enter the text aabba then java will scan it and finish the pattern by outputting aabbaabbaa etc.

  2. #2
    ojn
    ojn is offline Senior Member
    Join Date
    Aug 2008
    Location
    Stockholm, Sweden
    Posts
    119
    Rep Power
    0

    Default

    Check out String and Pattern classes in the API.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,564
    Rep Power
    23

    Default

    What is the relationship between: aabba and aabbaabbaa?
    How do you generate one from the other?
    It would look like the first string is reversed and concatentated to itself.
    What does "finish the pattern" mean?

  5. #5
    whosadork is offline Member
    Join Date
    Sep 2008
    Posts
    29
    Rep Power
    0

    Default

    srry, i meant continue the pattern, like if you entered abbabb then it will find a pattern

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,564
    Rep Power
    23

    Default

    entered abbabb then it will find a pattern
    So is the pattern for that: abb ?

    What is your design or ideas so far?

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    I think he wants to find a pattern 'aabba' and modified it to get the output as 'aabbaabbaa'

    Better to explain it well, lots of misunderstand here.

  8. #8
    linux0kernel is offline Member
    Join Date
    Oct 2008
    Posts
    19
    Rep Power
    0

    Default

    i don't understand your means! ~~~
    you can print it twice if you entered the 'aabba' ! The pattern is your input something!CODE
    Java Code:
    Pattern p = Pattern.compile(input);
    Matcher m = p.matcher(input);
    while(m.find()) {
        System.out.print(input + input);
    }
    while()
    but it's very worthless!

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    As Norm says in his last post, it's depends on the design.

    The way you explain is not much bad actually. But think if you found the same string 100 times. So how many string objects you have to instantiate. Even Java has garbage collector, I don't think it's a good idea.

Similar Threads

  1. Bean Patterns
    By Sysem in forum New To Java
    Replies: 0
    Last Post: 05-26-2008, 07:33 PM
  2. Replies: 2
    Last Post: 07-04-2007, 06:58 AM
  3. Design patterns
    By Freddie in forum New To Java
    Replies: 2
    Last Post: 05-12-2007, 06:21 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
  •