Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.knugi;
- public class AddForLength {
- public static void main(String args[]){
- int g = 1234;
- String a = ""+g;
- int result = 0;
- for(int i=0; i<a.length();i++){
- result+= (Integer.parseInt(a.substring(i, i+1)));
- }
- System.out.println("Wynik: "+result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment