User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.
Okay, so, I am working on porting an IM client over from autoit to java, and I'm still rather new to java.
What I am attempting to do is create a 2d array where I can store every user's conversation history in the array next to their name.
Then what I want to do, is, on demand, write this chat history into an edit control, by providing the user's username, thus showing the chat history with that user on screen when asked.
//...//array == {"no","no","yes","no","","yes",...}for(int i =0; i <99; i++){if(array[i].equals("yes")){// do somethingreturn something;}}// this will stop at i == 2 and will not reach the end of for loop
This would explain why you would get only first encounter from the array. I assume you want all the pieces of the conversation.
I assume the init() method adds data to the variable. In the code you provided, it doesn't add anything to the array so it is empty. This is why the conditions are never met and string "0" is returned. Also, the function of init() could have been done in the first line:
No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that
you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice
sessions to improve your knowledge and scores.
manpreet
Best Answer
3 years ago
Okay, so, I am working on porting an IM client over from autoit to java, and I'm still rather new to java.
What I am attempting to do is create a 2d array where I can store every user's conversation history in the array next to their name.
Then what I want to do, is, on demand, write this chat history into an edit control, by providing the user's username, thus showing the chat history with that user on screen when asked.
Tried several variations of code.
Array functions: