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
/**
* 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
3 Comments
thanks for sharing this article with us keep sharing.
ReplyDeletethanks for sharing this blog.
ReplyDeletebest training institute in Bangalore
full stack developer course
ReplyDelete