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
4 Comments
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletePython Training in electronic city
DataScience with Python Training in electronic city
AWS Training in electronic city
Big Data Hadoop Training in electronic city
Devops Training in electronic city
thanks for sharing this article with us keep sharing.
ReplyDeletethanks for sharing this blog.
ReplyDeletebest training institute in Bangalore
full stack developer course
ReplyDelete