public class Testing {
void Method(String input ) {
int array[] = new int[30];
for (int i=0; i<input.length(); i++)
{
char ch = input.charAt(i);
int asciiNum = (int) ch;
System.out.println ("For Character:" + ch + "int ascii valu is;" +
asciiNum);
int digit1=asciiNum % 10;
int temp = asciiNum /10;
int digit2 = temp %10;
temp = temp /10;
int digit3 = temp%10;
System.out.println ("The digits are:" + digit1 + "," + digit2 +
","+digit3);
array [i*3+0]=digit1;
array [i*3+1]=digit2;
array [i*3+2]=digit3;
}
for(int i=0 ; i<array.length;i++) {
System.out.println(array[i]);
}
}
public static void main(String[] args) {
Testing t1 = new Testing();
t1.Method("java");
}
}
Thanks and regards,
Rajeev Singla
602-284-1461
On Tue, Apr 19, 2011 at 6:12 PM, zhang chun <[email protected]> wrote:
> Hi Guy
> my code below, keep getting a error message "array required, but
> int found" how can i fix it?
>
>
> for (int i=0; i<input.length(); i++)
> {
> char ch = input.charAt(i);
> int asciiNum = (int) ch;
> System.out.println ("For Character:" + ch + "int ascii value
> is;" + asciiNum);
>
> digit1=asciiNum % 10;
> temp = asciiNum /10;
> digit2 = temp %10;
> temp = temp /10;
> digit3 = temp%10;
> System.out.println ("The digits are:" + digit1 + "," + digit2 +
> "," +digit3);
> int array;
> array [i*3+0]=digit1;
> array [i*3+1]=digit2;
> array [i*3+2]=digit3;
>
> }
>
> --
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en