This is my code:
import java.io.*;
import java.util.*;
public class Testing {
public static void main(String[] args) {
Scanner in = new Scanner(System.in );
PrintStream out = System.out;
String input = in .next();
String output = "";
char c = 0;
int count = 0;
int countInput = input.length();
for (int i = 0; i < countInput; i++) {
if (i == 0) {
c = input.charAt(i);
count++;
} else {
if (c == input.charAt(i)) {
count++;
} else {
output = output + count + "" + c;
count = 1;
c = input.charAt(i);
out.println(output);
}
}
}
output = output + count + "" + c;
out.println(output);
}
}
This program is suppose to work like this:
Input:
java Testing AAAAAnnnfffkk
Output:
5A3n3f2k
I need to fix this somehow:
String input = in.next();
I think args has to be used somewhere, I'm not sure where though.
in? That may help us help you.