JAVA | calculate-digit-sum-of-a-string
\nclass Solution {\n    public String digitSum(String s, int k) {\n        if(s.length()<=k)return s;\n        while(s.length()>k)\n        {\n            Strin
```\nclass Solution {\n    public String digitSum(String s, int k) {\n        if(s.length()<=k)return s;\n        while(s.length()>k)\n        {\n            String str="";\n            int left=s.length()%k;\n            for(int i=0;i<s.length()-left;i+=k)\n            {\n                str+=(sumstring(s.substring(i,i+k)));\n            }\n            if(s.length()%k!=0)str+=(sumstring(s.substring(s.length()-left,s.length())));\n            s=str;\n            System.out.println(s);\n        }\n        return s;\n        \n    }\n    \n    public String sumstring(String str){\n        int sum=0;\n        for(char i:str.toCharArray())\n        {\n            sum+=(i-\'0\');\n        }\n        return String.valueOf(sum);\n    }\n}\n```
['String', 'Java']