StringBuilder - Java

String Builder :


String Builder is often used if you want use string concatenation very often.


Time complexity will be O(N).


package com.techyield.operationsinarray;

public class StringBuilder {

public static void main(String[] args) {

int n = 10000;
StringBuilder str = new StringBuilder("Hello");
for(int i =0 ; i < n ; i++) {
str.append("satya");
}
String s = str.toString();
}



}

No comments:

Post a Comment

Featured Post

H1B Visa Stamping at US Consulate

  H1B Visa Stamping at US Consulate If you are outside of the US, you need to apply for US Visa at a US Consulate or a US Embassy and get H1...