Monday, September 28, 2020

Java String Class and its method Program

 public class MyClass

{

    public static void main(String args[]) 

    {

       String a = new String("College");

        String b  = new String("Sushmit");

        String z  = new String("Sushmit");

        System.out.println("value of a -> " + a);

       System.out.println("value of b -> " + b);

       System.out.println("Converting string into upper case -> " + a.toUpperCase());

      

      String c = b.toUpperCase();

      System.out.println("Converting string into upper case -> " + c);

      

      boolean res;

      

      c = c.toLowerCase();

      System.out.println("Converting string into Lower case -> " + c);   

      c = a.replace('S','x');

      System.out.println("Converting string into Lower case -> " + c);   

      

      res = a.equals(b);

      System.out.println("Output is  -> " + res);  

      System.out.println("Output is  -> " + a.equals(b));  

      

      res = z.equals(b);

      System.out.println("Output is  equal -> " + res);  

      System.out.println("Output is  equal -> " + z.equals(b));  

      

      res = z.equalsIgnoreCase(b);

      System.out.println("Output is  Ignore Case -> " + res);  

      System.out.println("Output is  Ignore Case -> " + z.equalsIgnoreCase(b));  

      

      int count;

      count = z.length();

      System.out.println("Output is  Length -> " + count);    

      System.out.println("Output is  Length -> " + z.length());

      

      System.out.println("Output is  Length -> " + z.charAt(4));  

      

      

      count = b.compareTo(z);  

      System.out.println("Output is Compare to  -> " + count);  

      System.out.println("Output is  Compare to -> " + b.compareTo(z));     

      

      

      z = b.concat(z);  

      System.out.println("Output is Concate  -> " + z);  

      System.out.println("Output is  Concate -> " + b.concat(z));     

      

      System.out.println("Output is  SUbstring  -> " + a.substring(11));   

      System.out.println("Output is  SUbstring  -> " + a.substring(4,8));   

      

      

       System.out.println("Output is  Value of  -> " + String.valueOf(c));   

       System.out.println("Output is  Index of  -> " + a.indexOf('s'));   

       System.out.println("Output is  Index of  -> " + a.indexOf('s',3));   

        

    }

}



No comments:

Post a Comment

Financial Year Oracle PLSQL Program

 CREATE OR REPLACE function FINANCIAL_YEAR(p_date DATE) return varchar2 IS    v_first     varchar2(4);    v_second    varchar2(4);    v_year...