i am sending value from one page to another,i want to store the values which i hav sent,& then want to compare the value which i am sending with the one which i hav already sent,i.e the saved value.while storing the values into an arrayin persistent object,& then comparing the value with another array,i face some prob,can anyone tell me how to check whether a value already exits in the array,i am giving the code,kindly help
package com.firstBooks.series.db;
import java.util.Random;
import net.rim.device.api.system.PersistentObject;
import net.rim.device.api.system.PersistentStore;
import net.rim.device.api.util.Arrays;
import net.rim.device.api.util.Persistable;
import com.firstBooks.series.db.parser.XMLParser;
import com.firstBooks.series.ui.managers.TopManager;
import com.firstBooks.series.ui.screens.TestScreen;
public class DBMain implements Persistable{
public static String answer = "";
public static String selectedAnswer = "";
public static Question curQuestion;
public static int currQuesNumber = 1;
public static int correctAnswerCount = -1;
static int curQuesnew;
static int quesCount=-1;
static int xyz;
static int j=0;
public static int totalNumofQuestions = Question.totques;
public static int quesNum[] = new int[XMLParser.questionList.size()];
static PersistentObject qStore;
static PersistentObject curQues;
static PersistentObject pQues;
static PersistentObject curans;
static PersistentObject disques;
static PersistentObject restques;
static int a ;
static int b;
static int[] c ;
static int[] d ;
static int pques;
static int cans;
static int[] dques;
static int[] rques;
static {
qStore = PersistentStore.getPersistentObject(0x33010065d24c7883L);
curQues = PersistentStore.getPersistentObject(0x33010064d24c7883L);
pQues = PersistentStore.getPersistentObject(0xbd7460a5b4f9890aL);
curans = PersistentStore.getPersistentObject(0xc5c065a3ae1bec21L);
disques = PersistentStore.getPersistentObject(0xbf8118045165a07aL);
}
static{
initialize();
}
public static void initialize() {
//int quesNum[] = new int[XMLParser.questionList.size()];
Random rgen = new Random(); // Random number generator
//int a=Integer.parseInt(TopManager.quesNumber);
//System.out.println("The value of AAAAAAA is...."+a);
// --- Initialize the array
for (int i = 0; i < quesNum.length; i++) {
quesNum[i] = i;
}
// --- Shuffle by exchanging each element randomly
for (int i=0; i< quesNum.length; i++) {
int randomPosition = rgen.nextInt(quesNum.length);
int temp = quesNum[i];
quesNum[i] = quesNum[randomPosition];
quesNum[randomPosition] = temp;
}
synchronized (qStore) {
qStore.setContents(quesNum);
qStore.commit();
}
}
public static int getQuestionNumber() {
//int quesCount;
//quesCount++;
//synchronized (curQues) {
//quesCount = Integer.parseInt((String)curQues.getContents());
//}
quesCount++;
synchronized (curans) {
int b=Integer.parseInt(TopManager.corrCount);
curans.setContents(b+"");
curans.commit();
}
//int quesNum[];
synchronized (qStore) {
quesNum=(int[]) qStore.getContents();
System.out.println("The value of question is ...."+quesNum.length);
}
synchronized (pQues) {
int a=Integer.parseInt(TopManager.quesNumber);
pQues.setContents(a+"");
pQues.commit();
}
if (quesNum!=null && quesCount < quesNum.length) {
synchronized (curQues) {
curQuesnew=quesNum[quesCount];
curQues.setContents(curQuesnew+"");
curQues.commit();
}
synchronized (disques) {
c[j]=TestScreen.quesNumber;
System.out.println("Astala vistaaaaaaaaaaaaa"+c);
disques.setContents(c+"");
disques.commit();
}
synchronized (disques) {
dques[j]=Integer.parseInt((String)disques.getContents());
System.out.println("valueee is.........."+dques);
}
for(int k=0;k<dques.length;k++){
if(quesNum[quesCount]!=dques[k]){
System.out.println("ghijyghfhgfhfhgfhgfhgfhgfhgddkjklmn");
xyz=quesNum[quesCount];
}
j++;
}
return xyz;
} else {
initialize();
quesCount = -1;
return getQuestionNumber();
}
}
public static int getpresentQuestionNumber(){
synchronized (pQues) {
pques=Integer.parseInt((String)pQues.getContents());
}
return pques;
}
public static int getCorrectanswerNumber(){
synchronized (curans) {
cans=Integer.parseInt((String)curans.getContents());
}
return cans;
}
public static int getCurrQuestionNumber() {
synchronized (curQues) {
return Integer.parseInt((String)curQues.getContents());
//return curQuesnew;
//curQuesnew=(int[]) curQues.getContents();
//return curQuesnew[quesCount];
}
}
}