What is different between replace, replaceAll and replaceFirst in String java example

Java code example for different between replace, replaceAll and replaceFirst in String.

public class Test {
        public static void main(String[] args) {       
            String st = new String("Test String Here");
            String st1 = new String("test string test here");
           
            String st2 = st.replace("Test", "New");
            System.out.println(st2);
           
            st2 = st1.replaceAll("test", "New");
            System.out.println(st2);
           
            st2 = st1.replaceFirst("test", "New");
            System.out.println(st2);
           
        }
}

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

Use of req.query, req.params and req.body in NODE JS

How to capture finger prints in java