9:31 pm - Thursday July 19, 2018

StringBuilder Example Program for insert(int offset,int i)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
*@author :CandidJava.com
*@descriptions : This program explains the function and use of method insert (int offset, double d) to insert the string representation of the integer argument into this sequence Stringbuilder s1
*/

public class StringInsert4
{
public static void main(String ar[]) throws Exception
{
StringBuilder s1=new StringBuilder("MyInteger:");
                                                       // object created for string builder with content ?MyInteger:?
int i=123;
System.out.println("Before inserted:"+s1);
s1=s1.insert(10,i);              //string representation of integer argument after 10th location
System.out.println("After inserted:"+s1);
}
}

OUTPUT:
Before inserted: MyInteger:
After inserted: MyInteger: 123

BACK

Filed in: Z-A All Java Codes

Comments are closed.