String Operations-Java Program

package Prog;

/**
 * The Class StringOperations //multiline comment
 */
public class StringOperations
{


public static void main(String a[]) throws ArrayIndexOutOfBoundsException
{
String str="my name is Ankit Vijay";
System.out.println(str.length());



//11 means 12 value in string .
char c=str.charAt(11);
System.out.println(c);

char cArray[]=str.toCharArray();
System.out.println(cArray);


byte  b[]=str.getBytes();
for (int i=0; i<b.length; i++)
{
System.out.print((char)b[i]);
}
System.out.println();



try
{
char[] d=new  char[5];
        str.getChars(11, 16, d, 0);
     
        System.out.println(d.length);
}

catch(ArrayIndexOutOfBoundsException e)
{
e.getMessage();
e.toString();

}

finally
{
System.out.println("final method");
}

}

}


Output:
--------------------------------------------------------------------------------------------------------------------------

22
A
my name is Ankit Vijay
my name is Ankit Vijay
5
final method

Post a Comment

3 Comments

Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)