Java: How to find out the position of a character in a String using StringBuffer.

Here, I want to share you a solution to find out the position of  characters  in a String using StringBuffer  in  java.



Code Example:



class StringManipulation


 public static void main(String args[])


StringBuffer str= new StringBuffer(“Software Engineering”);


System.out.println(“Original String:”+str);


System.out.println(“length of String:”+str.length());


 for(int i=0;i<str.length();i++)


int p=i+1;

System.out.println(“Character at position:”+p+”:is:”+str.charAt(i));







Character Position in a string java

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 348 other followers