I want to read char variable a
in a loop, and increment variable k
by one in each step of loop.
here is code in java:
public class Hello {
public static void main(String arg[]) throws IOException {
int k, i;
char a;
k=0;
for (i=0; i<=3; i++) {
k++;
a=(char) System.in.read();
System.out.println(k);
}
}
}
here is result:
A //variable a
1
2
3
B //variable a
4
i need this result:
a //variable a
1
c //variable a
2
b //variable a
3
y //variable a
4
maybe i need some other method to read CHAR in loop ( not SYSTEM.IN.READ() ), but i am new in java.