View Single Post
  #1 (permalink)  
Old 04-04-2008, 12:51 PM
googgoo googgoo is offline
Member
 
Join Date: Mar 2008
Posts: 8
googgoo is on a distinguished road
Help me ...urgent!
Hi !
I crate method Check() for comparing charArray and inputChar
In my code, I declared variable charArray such as char[] charArray={'A','N','T'}
and get input from keyboard each character and keep in variable inputChar
When get input 'A' I want compare charArray in index[0]
if equal ...to compare next index ...until last index equal then print "equal"
but my method not so,my method check char by char and no run on index.
How I solve this problem.
Code:
public static int Check(char[] charArray , char inputChar){ for(index = 0;index<len;index++){ if(charArray[index] == inputChar){ index++; if(index == len){ System.out.println("equals"); } } } return index; }
Reply With Quote
Sponsored Links