3:15 pm - Thursday November 15, 2018

StringBuilder Example Program for insert(int offset,double d)

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 double argument into this sequence Stringbuilder s1
*/
public class StringInsert2
{
public static void main(String ar[]) throws Exception
{
StringBuilder s1=new StringBuilder("Obtained: DoubleValue");
                                   // object created for string builder with content ?Obtained: DoubleValue?
double d=0.007;
System.out.println("Before inserted:"+s1);
s1=s1.insert(9,d); //string representation of double argument after 9th location
System.out.println("After inserted:"+s1);
}
}

OUTPUT:

Before inserted: Obtained: DoubleValue
After inserted: Obtained: 0.0070 DoubleValue

BACK

Filed in: Z-A All Java Codes

Comments are closed.