9:32 pm - Thursday July 19, 2018

StringBuilder Example Program for insert(int offset,float f)

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 float argument into this sequence Stringbuilder s1
*/
public class StringInsert3
{
public static void main(String ar[]) throws Exception
{
StringBuilder s1=new StringBuilder("MrHello");
                               // object created for string builder with content ?MrHello?
float f=1/5;
System.out.println("Before inserted:"+s1);
s1=s1.insert(2,f);   //string representation of float argument after 2nd location
System.out.println("After inserted:"+s1);
}
}

OUTPUT:

Before inserted: Obtained: MrHello
After inserted: Obtained: Mr0.0Hello

BACK

Filed in: Z-A All Java Codes

Comments are closed.