Study

String Library functions

  •   0%
  •  0     0     0

  • System.out.print("COMPUTER".substring(1,5));
    OMPU
  • System.out.println("india".equalsIgnoreCase("INDIA"));
    true
  • System.out.println("Today is Holiday".lastIndexOf(‘o’));
    10
  • String s = “malayalam”; System.out.println(s.indexOf(‘m’));
    0
  • String arr[]={“DELHI”, “CHENNAI”, “MUMBAI”, “LUCKNOW”, “JAIPUR”}; System.out.print(arr[4].substring(0,3));
    JAI
  • System.out.print( “CABLE”.compareTo(“CADET”));
    -2
  • String str1 = “great”; System.out.println((“WH” + (strl.substring(2).toUpperCase())));
    wheat
  • char x = ‘A’; int m; m=(x= =’a’) ? ‘A’ : ‘a’; System.out.println(“m=”+m);
    m=97
  • String arr[]={“DELHI”, “CHENNAI”, “MUMBAI”, “LUCKNOW”, “JAIPUR”}; System.out.print(arr[0].length()>arr[3].length());
    false
  • System.out.print(“MISSISSIPPI”.indexOf(‘S’)+“MISSISSIPPI”.lastIndexOf(‘I’));
    12
  • String n = “Computer Knowledge”; String m = “Computer Applications”; System.out.println(n.substring (0,8).concat(m.substring(9)));
    Computer Applications
  • String s=“Today is Test”; System.out.println(s.substring(0,7)+“ ”+“Holiday”);
    Today i Holiday
  • x="computer"; y="application";System.out.println(y+x.substring(5));
    applicationster
  • String s=“String”; int a=12,b=45; System.out.print(a+s+b);
    12String45
  • int n = "4.3756".indexOf(‘.’); System.out.print Integer.valueOf(s.substring(n+1));
    3756
  • String str1 = “great”; String str2 = “minds”; System.out.println(strl.substring(0,2).concat(str2.substring(1)));
    grinds