For practicing reasons I would like to write a method which inserts a character into a string.I would like to know:What is the best practice concerning placement of a comment within methods?  For example, is the way that I commented about what raises an exception fine, or are there better practices?  Would I need more comments, and if so, where? In this particular example, are throwing unchecked exceptions preferred or checked?How can I make this method more reliable?How can I make this method more scalable?While dealing with immutable strings there are always discussions around performance. Can I make this method run faster?Is this code thread safe?/** * Inserts the character ch at the location index of string st * @param st * @param ch * @param index * @return a new string  */    public static String insertCharAt(String st, char ch, int index){        //1 Exception if st == null        //2 Exception if index<0 || index>st.length()        if (st == null){            throw new NullPointerException(Null string!);        }        if (index < 0 || index > st.length())        {            throw new IndexOutOfBoundsException(Try to insert at negative location or outside of string);        }        return st.substring(0, index)+ch+st.substring(index, st.length());    }
Insert a character into a string
java;strings;exception;immutability