package stringfunc;
public class Stringfunc {
public static void main(String[] args) {
//1.comaprison functions boolean/ contenets of Strings/ 5 functions
String s="Jordan";
// System.out.println(s.equals("JORDAN"));// حالة الحرفcapital small (false)
s.equals(" ")
// System.out.println(s.equals("Jordan"));// حالة الحرفcapital small (false)
s.equals(" ") true
//System.out.println(s.equalsIgnoreCase("jordan"));// ما بفرق اذا كان الحرفcaptial
or small true
//System.out.println(s.equalsIgnoreCase("Jordan"));// ما بفرق اذا كان الحرفcaptial
or small true
// System.out.println(s.startsWith("jo"));// تاخد حالة الحرف بعين االعتبارfalse
// System.out.println(s.startsWith("Jo"));//true
// System.out.println(s.endsWith("AN")); //المقارنة بتكون بالنهاية بتاخد خالة الحرف
بعين االعتبارfalse
// System.out.println(s.endsWith("an"));//true
String s2="Hashemite Universtity"; //Hash
String s3="Hashemite universtity";
String s4="hashemite universtity";//hash
// regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int
lenght)
// System.out.println(s2.regionMatches(true,0, s3, 0, 4));// اتجاهل حالة الحرف النو
اولparameter كانtrue (true)
// System.out.println(s2.regionMatches(false,0, s4, 0, 4));// يفرقcaptital عنsmall
false
//System.out.println(s2.regionMatches(true,0, s3, 1, 4));
//System.out.println(s2.regionMatches(0, s4, 0, 4));// حالة الحرف ماخوذة بعين
االعتبار
// System.out.println("***************************************");
//String Length, Characters, and Combining Strings function
String str1="Welcome";
String str2=" to Summer Semester ";
// System.out.println(str1.length()); // عدد االحرف اللي فيstring 7
// System.out.println(str1.charAt(3));//c
//System.out.println(str1.charAt(7));
// System.out.println(str1.concat(" to java class"));//+//weclome to java class
// System.out.println(str1.concat(str2));//welcome to summer Semester
// System.out.println("***************************************");
//3.Extracting String function
String sr1 = "Welcome to Java";
//startindex end-1[0-10]
String sr2 = sr1.substring(0, 11) + "HTML";// Welcome to HTML
// System.out.println(sr2);
//start index-to the end ot String
// System.out.println(sr1.substring(11));//Java
/*
System.out.println("Welcome".toLowerCase()); //all letters to small letters
System.out.println("Welcome".toUpperCase());
System.out.println(" Welcome ".trim());//cut white spaces from both start and end
of str...
System.out.println(" Welo cme ".trim());//Welo cme
System.out.println("Welcome".replace('e', 'A') );// ايe ' بتالقي بتغيروA' WAlcomA
System.out.println("Welcome".replaceFirst("e", "AB") );//WABlcome اول وحدة بتالقيها
System.out.println("Welcome".replace("e", "AB") );//ًWABlcomAB
System.out.println("Welcome".replace("el", "AB") );//WABcome
*/
System.out.println("***************************************");
//Coverting from char ,int , array of char , long to String
System.out.println(String.valueOf(5.44));//double =>String "5.44"
System.out.println(String.valueOf(6));//int => String "6"
char ch[]={'a','m','b'};
String stt=String.valueOf(ch);//array of character to string "amb"
System.out.println(stt);//amb
long l=789456;
String lo=String.valueOf(l);//long to String
System.out.println(lo);// "789456"
System.out.println("***************************************");