السؤال كالتالي:
Write a method int matchSub(String s, String substring); that returns the first position where the substring is found in s. Note: use String methods. Write a main() to test this.
الرجاء المساعدة ولكم جزيل الشكر
السؤال كالتالي:
Write a method int matchSub(String s, String substring); that returns the first position where the substring is found in s. Note: use String methods. Write a main() to test this.
الرجاء المساعدة ولكم جزيل الشكر
السلام عليكم ورحمة الله وبركاته
Write a method int matchSub(String s, String substring); that returns the first position where the substring is found in s. Note: use String methods. Write a main() to test this.
Soulution ( الحل ) :-
public class TestingSub {
public static void main(String []args) {
String test = "WelcomeToJavaWorld";
String testSub = "Java";
int index = matchSub1(test,testSub);
System.out.println("The First Position where the substring \"Java\" where found: " + index);
}
public static int matchSub1(String s, String substring) {
String ss = s;
String sub = substring;
return ss.indexOf(sub);
}
}ملاحظه: يجب ان يكون الكود في ملف اسمه TestingSub.java
تم تعديل هذه المشاركة بواسطة عيسى عايد العنزي في 27 أكتوبر 2007 في 10:50 — السبب: اضافة كود تاق
أهلاً نواف !
شكراً لمشاركتك واتمنى ان اراك دائما معنا
اولا اشكر الاخ عيسى على التكرم بالرد
ثانيا اشكرك اخي نواف جزيل الشكر على الحل الرائع وجزاك الله خيرا يا اخي
هذا الموضوع مغلق.