Friday, 10 March 2017

What is String and main string methods used in selenium

Case 1: Case ignore case in string object:-
String s1="Male";
String s2 ="MALE";
if(s1.equalsIgnoreCase(s2) use;
Case 2: Splitting decimal numbers:-
      String s="50.02";
       String arr[]=s.split("\\.");
       for(int i=0;i<arr.length;i++)
       System.out.println(arr[i]);
Case 3. continue statement
            int [] numbers = {10, 20, 30, 40, 50};

             for(int x : numbers ) {
                if( x == 30 ) {
                    continue;
                }
                System.out.print( x );
                System.out.print("\n");
Case 4:- Ternary operands and alternate way of the if -else
             int a =30,b=40;
              System.out.println(a>b?"true" :"false");
Case 5:Character class cases:-
           1.   Character ch = 'a';
              System.err.println(ch);  =a
     2 Character ch = '1';
       System.err.println(ch.isLetter(ch)); =false

     3. Character ch = '1';
              System.err.println(ch.isDigit(ch));=true

     4. Character ch = ' ';
              System.err.println(ch.isWhitespace(ch));  ==true

     5. Character ch = 'a';
              System.err.println(ch.isUpperCase(ch));==false

     6. Character ch = 'n';
              System.err.println(ch.isLowerCase(ch));==true

     7. Character ch = 'n';
              System.err.println(ch.toString());==One char string   

Case 6:
          String s="25.23";
              Double d=Double.parseDouble(s);
              double dd=d.doubleValue();
              double db= 25.23;
              if (dd==db)
              System.out.println("Equal");

Case 7:        String s="25.23";
              double d= Double.parseDouble(s);

case 8: List in single line initialze
ArrayList<Integer> al= new ArrayList<Integer>(Arrays.asList(10,20,30,50,60,80));

Go Back

No comments:

Post a Comment

Download Android SDK

Download Android SDK tools Follow me on Instagram - https://www.instagram.com/virenautomationtesting/ Follow me on Twitter- https://twitt...