Friday, 15 February 2013

Java example which replaces character present at particular position

public class StringTest {


    public static void main(String[] args)
    {
        int i =0;
        for(char c: test.toCharArray())
        {
            System.out.println(i++ + "=" + c);
        }
       
        String sample = "akckekghkjklmnopqrstuvwxyz";
        System.out.println(sample);
        char c = sample.charAt(10);
        System.out.println(c);
        System.out.println("test "+sample.substring(0, 10));
        System.out.println(getStringByReplacingTenthPosition(sample).length());

    }

    private static String getStringByReplacingTenthPosition(String sample) {
        return sample.substring(0, 10) + " " + sample.substring(11);
    }
}

No comments:

Post a Comment

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...