Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author stud-b11704
- */
- public class Sub
- {
- public boolean findSub(String text, String sText)
- {
- for(int i = 0; i < text.length(); i++)
- {
- for(int i2 = 0; i2 < sText.length(); i2++)
- {
- if(i == text.length()-1)
- {
- return false;
- }
- if(sText.charAt(i2) == text.charAt(i))
- {
- i++;
- if(i2 == sText.length()-1)
- {
- System.out.println(i - sText.length());
- return true;
- }
- }
- else
- {
- break;
- }
- }
- }
- return false;
- }
- }
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author stud-b11704
- */
- public class Start
- {
- public static void main(String args[])
- {
- Sub s = new Sub();
- System.out.println(s.findSub("Ala ma kota", "tama"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement