
in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic for this

import java.awt.*;
import javax.swing.*;
class Header{
public static void main(String []args){
String st1="123456 ABC DEF";
int index=st1.indexOf(' ');
String st2="raveen"+" ";
StringBuffer sb = new StringBuffer(st1);
String st3= sb.insert(index+1, st2).toString();
JFrame f=new JFrame(st3);
f.setLayout(null);
JLabel l=new JLabel(st3);
l.setBounds(50,10,300,20);
f.add(l);
f.setSize(300,100);
f.setVisible(true);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.